[英]iOS Tab Bar Image Size Increasing On Tap
I have a tab bar on iOS and I set the tab bar images using SVGs. 我在iOS上有一个标签栏,并使用SVG设置了标签栏图像。 The SVGs are set via the XamSvg plugin . 通过XamSvg插件设置SVG 。
I want the central tabbar item image to be larger than the ones on the other tabs. 我希望中央标签栏项图像大于其他选项卡上的图像。 To do so, I use this code in 为此,我在
In AwakeFromNib: 在AwakeFromNib中:
CenterTab.Image = SvgFactory.FromBundle(ViewModel.Images.CenterTabSvg, 24);
CenterTab.ImageInsets = new UIEdgeInsets(-5, -5, -5, -5);
It works but every time I tap on the center tab, its image size keeps increasing. 它可以工作,但是每次我点击中心选项卡时,它的图像大小都会不断增加。
I also tried this with no success: 我也尝试了这个但没有成功:
var centerImage = SvgFactory.FromBundle(ViewModel.Images.CenterTab, 40).ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
CenterTab.SetFinishedImages(centerImage,centerImage);
centerImage.ImageInsets = new UIEdgeInsets(3,-13,-5,-5);
Try This : 尝试这个 :
UITabBarItem *centerTab = [self.tabBarController.tabBar.items objectAtIndex:2];
[centerTab setImage:[[UIImage imageNamed:@"iconGray.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];//Your Image
[centerTab setSelectedImage:[[UIImage imageNamed:@"iconBlue.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];//Your Image
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.