switch wifi icon to svg

This commit is contained in:
TrueZhuanjia
2025-06-01 14:30:02 +08:00
parent 7f23c4a508
commit 8c8fea0d4b
3 changed files with 73 additions and 33 deletions
+14 -33
View File
@@ -68,7 +68,7 @@ static const float REFRESH_CYCLE = 2.0f;
}
else
{
UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(hostLongClicked:)];
UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(hostCardLongPressed:view:)];
[self addGestureRecognizer:longPressRecognizer];
}
@@ -268,27 +268,6 @@ static const float REFRESH_CYCLE = 2.0f;
self.hostNameLabel.font = [UIFont boldSystemFontOfSize:18*_sizeFactor];
[self addSubview:self.hostNameLabel];
// 在线状态图标
self.statusIcon = [[FixedTintImageView alloc] initWithFrame:CGRectMake(180, 70, 20*_sizeFactor, 20*_sizeFactor)];
self.statusIcon.contentMode = UIViewContentModeScaleAspectFit;
self.statusIcon.translatesAutoresizingMaskIntoConstraints = NO;
if (@available(iOS 13.0, *)) {
self.statusIcon.image = [UIImage systemImageNamed:@"wifi"];
} else {
// Fallback on earlier versions
}
self.statusIcon.tintColor = defaultGreen;
[self addSubview:self.statusIcon];
[NSLayoutConstraint activateConstraints:@[
[self.statusIcon.leadingAnchor constraintEqualToAnchor:self.hostNameLabel.leadingAnchor],
[self.statusIcon.topAnchor constraintEqualToAnchor:self.hostNameLabel.bottomAnchor constant:0*_sizeFactor],
[self.statusIcon.widthAnchor constraintEqualToConstant:16*_sizeFactor]
]];
// 在线文字
self.statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(205, 68, 100, 24)];
self.statusLabel.translatesAutoresizingMaskIntoConstraints = NO;
@@ -296,14 +275,23 @@ static const float REFRESH_CYCLE = 2.0f;
self.statusLabel.font = [UIFont systemFontOfSize:15*_sizeFactor weight:UIFontWeightMedium];
self.statusLabel.textColor = defaultGreen;
// self.statusLabel.font = [UIFont systemFontOfSize:16*_sizeFactor];
// 在线状态图标
self.statusIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 16*_sizeFactor, 16*_sizeFactor)];
self.statusIcon.contentMode = UIViewContentModeScaleAspectFit;
self.statusIcon.translatesAutoresizingMaskIntoConstraints = NO;
self.statusIcon.image = [[UIImage imageNamed:@"wifi_green"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// self.statusIcon.tintColor = defaultGreen;
[self addSubview:self.statusIcon];
[self addSubview:self.statusLabel];
[NSLayoutConstraint activateConstraints:@[
[self.statusLabel.leadingAnchor constraintEqualToAnchor:self.statusIcon.trailingAnchor constant:3*_sizeFactor],
[self.statusLabel.centerYAnchor constraintEqualToAnchor:self.statusIcon.centerYAnchor constant:0],
[self.statusLabel.topAnchor constraintEqualToAnchor:self.hostNameLabel.bottomAnchor constant:0*_sizeFactor],
[self.statusIcon.centerYAnchor constraintEqualToAnchor:self.statusLabel.centerYAnchor constant:0],
[self.statusIcon.leadingAnchor constraintEqualToAnchor:self.hostNameLabel.leadingAnchor],
[self.statusIcon.widthAnchor constraintEqualToConstant:16*_sizeFactor]
]];
// 启动应用按钮
self.appButton = [UIButton buttonWithType:UIButtonTypeSystem];
self.appButton.translatesAutoresizingMaskIntoConstraints = NO;
@@ -532,15 +520,8 @@ static const float REFRESH_CYCLE = 2.0f;
[_hostSpinner stopAnimating];
_statusLabel.textColor = defaultGreen;
_statusLabel.text = @"Online";
_statusIcon.tintColor = defaultGreen;
if (@available(iOS 13.0, *)) {
_statusIcon.image = [UIImage systemImageNamed:@"wifi"];
} else {
// Fallback on earlier versions
}
self.statusIcon.image = [[UIImage imageNamed:@"wifi_green"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
_hostIconView.tintColor = [UIColor whiteColor];
_appButton.titleLabel.font = [UIFont systemFontOfSize:16*_sizeFactor];
if(host.pairState == PairStatePaired){
_iconBackgroundView.backgroundColor = defaultBlue;
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "wifi_green.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,38 @@
<svg width='54.935546875px' height='35.44921875px' direction='ltr' xmlns='http://www.w3.org/2000/svg' version='1.1'>
<g fill-rule='nonzero' transform='scale(1,-1) translate(0,-35.44921875)'>
<path fill='#34C759' stroke='#34C759' stroke-width='1.0' d='
M 6.982421875,21.076171875
C 7.283203125,20.775390625 7.69140625,20.775390625 7.9921875,21.09765625
C 13.01953125,26.33984375 19.8515625,29.240234375 27.45703125,29.240234375
C 35.044921875,29.240234375 41.8984375,26.447265625 46.943359375,21.09765625
C 47.244140625,20.775390625 47.65234375,20.775390625 47.953125,21.076171875
L 50.359375,23.482421875
C 50.6171875,23.76171875 50.6171875,24.1484375 50.380859375,24.44921875
C 45.611328125,30.25 36.48046875,34.33203125 27.45703125,34.33203125
C 18.455078125,34.33203125 9.302734375,30.271484375 4.5546875,24.44921875
C 4.318359375,24.1484375 4.33984375,23.76171875 4.576171875,23.482421875
Z
M 15.576171875,12.439453125
C 15.8984375,12.138671875 16.2421875,12.138671875 16.607421875,12.525390625
C 19.20703125,15.318359375 23.439453125,17.208984375 27.45703125,17.1875
C 31.49609375,17.208984375 35.728515625,15.318359375 38.328125,12.525390625
C 38.693359375,12.138671875 39.037109375,12.138671875 39.359375,12.439453125
L 42.130859375,15.16796875
C 42.3671875,15.42578125 42.41015625,15.76953125 42.173828125,16.048828125
C 39.1875,19.765625 33.38671875,22.2578125 27.45703125,22.2578125
C 21.548828125,22.2578125 15.76953125,19.744140625 12.76171875,16.048828125
C 12.525390625,15.76953125 12.568359375,15.42578125 12.8046875,15.16796875
Z
M 27.45703125,1.1171875
C 27.7578125,1.1171875 28.037109375,1.310546875 28.724609375,1.955078125
L 33.580078125,6.6171875
C 33.81640625,6.83203125 33.880859375,7.08984375 33.623046875,7.412109375
C 32.52734375,8.89453125 29.9921875,10.205078125 27.45703125,10.205078125
C 24.943359375,10.205078125 22.408203125,8.89453125 21.3125,7.412109375
C 21.09765625,7.08984375 21.119140625,6.83203125 21.35546875,6.6171875
L 26.2109375,1.955078125
C 26.8984375,1.267578125 27.177734375,1.1171875 27.45703125,1.1171875
Z
' />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB