Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.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/0/iphone/37.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 为iPhone应用定制工具栏_Ios_Iphone_Uibarbuttonitem_Uitoolbar - Fatal编程技术网

Ios 为iPhone应用定制工具栏

Ios 为iPhone应用定制工具栏,ios,iphone,uibarbuttonitem,uitoolbar,Ios,Iphone,Uibarbuttonitem,Uitoolbar,我想更改我的uibarbuttonims的图像,但不带颜色,也不调整大小。 我在导航栏上的按钮很好 这是我的方法: UIButton *mySettingsButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *settingsImage = [UIImage imageNamed:@"settings-greyscale.png"]; mySettingsButton.frame = CGRectM

我想更改我的uibarbuttonims的图像,但不带颜色,也不调整大小。 我在导航栏上的按钮很好

这是我的方法:

    UIButton *mySettingsButton = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *settingsImage = [UIImage imageNamed:@"settings-greyscale.png"];
    mySettingsButton.frame = CGRectMake(0.0, 0.0, settingsImage.size.width, settingsImage.size.height);
    [mySettingsButton setBackgroundColor:[UIColor clearColor]];
    [mySettingsButton setImage:settingsImage forState:UIControlStateNormal];
    [mySettingsButton addTarget:self action:@selector(performSettingsSegue)  forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *mySettingsBarButton = [[UIBarButtonItem alloc] initWithCustomView:mySettingsButton];
    UIBarButtonItem *settingsBarButton = (UIBarButtonItem *)[self.view viewWithTag:1000];
    settingsBarButton = mySettingsBarButton;
我不知道该怎么办。甚至有可能去除工具箱中的巴布托石?我只想我的形象没有任何变化。 我该怎么办


提前谢谢

问题出在UIButton初始化代码中,请尝试以下操作:

UIButton *mySettingsButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *settingsImage = [UIImage imageNamed:@"settings-greyscale.png"];
mySettingsButton.frame = CGRectMake(0.0, 0.0, sttingsImage.size.width, settingsImage.size.height);
/* then your code */

我把帖子改成了你的解决方案。你是这样想的吗?但是它不起作用。。