Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iOS 7中更改中央选项卡栏按钮的颜色?_Ios_Objective C_Ios7_Uibutton_Uinavigationitem - Fatal编程技术网

如何在iOS 7中更改中央选项卡栏按钮的颜色?

如何在iOS 7中更改中央选项卡栏按钮的颜色?,ios,objective-c,ios7,uibutton,uinavigationitem,Ios,Objective C,Ios7,Uibutton,Uinavigationitem,我希望我的uitabarcontroller中的中间按钮具有与其他按钮不同的颜色,例如Instagram。有人有什么建议吗?您应该为每个tabBarItem图像设置不同的颜色(如果您希望它像instagram一样) 这里有一个例子: UITabBarItem *tabBarItem = [yourTabBarController.tabBar.items objectAtIndex:2]; //set objectAtIndex you want (For Instagram its 2) U

我希望我的
uitabarcontroller
中的中间按钮具有与其他按钮不同的颜色,例如Instagram。有人有什么建议吗?

您应该为每个
tabBarItem
图像设置不同的颜色(如果您希望它像instagram一样)

这里有一个例子:

UITabBarItem *tabBarItem = [yourTabBarController.tabBar.items objectAtIndex:2]; //set objectAtIndex you want (For Instagram its 2)

UIImage *unselectedImage = [UIImage imageNamed:@"unselected-imagename"]; //set unselected image
UIImage *selectedImage = [UIImage imageNamed:@"selected-imagename"]; //set selected image

[tabBarItem setImage: [unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem setSelectedImage: selectedImage];
希望这有帮助:)


干杯

这只会更改按钮的图片,我希望里面有图片的矩形按钮具有不同的颜色。我希望矩形按钮,然后创建一个矩形图像。。。