Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.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/9/ios/98.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
Iphone 如何设置UIBarButtonItem灵活空间的图像-IOS_Iphone_Ios_Cocoa Touch_Uibarbuttonitem_Uitoolbar - Fatal编程技术网

Iphone 如何设置UIBarButtonItem灵活空间的图像-IOS

Iphone 如何设置UIBarButtonItem灵活空间的图像-IOS,iphone,ios,cocoa-touch,uibarbuttonitem,uitoolbar,Iphone,Ios,Cocoa Touch,Uibarbuttonitem,Uitoolbar,看看这张图片 我想这样设计工具栏,每个uibarbuttonite应该用一条细线隔开。因此,我在每个uibarbuttonite之间插入了灵活的空格按钮(这有助于我在方向改变时对齐uibarbuttonite),但是,如果我为此设置了一个图像,它将不再充当灵活按钮,而是更改为正常UIBarbutton 所以我需要一个灵活的带有图像的空格键。。你知道怎么做吗。 (或) 如何像上面那样设计UIToolbar。。。非常感谢您的帮助。Thanx为uibarbuttonite设置背景图像 UIImage

看看这张图片

我想这样设计工具栏,每个uibarbuttonite应该用一条细线隔开。因此,我在每个uibarbuttonite之间插入了灵活的空格按钮(这有助于我在方向改变时对齐uibarbuttonite),但是,如果我为此设置了一个图像,它将不再充当灵活按钮,而是更改为正常UIBarbutton

所以我需要一个灵活的带有图像的空格键。。你知道怎么做吗。 (或)
如何像上面那样设计UIToolbar。。。非常感谢您的帮助。Thanx

为uibarbuttonite设置背景图像

UIImage *faceImage = [UIImage imageNamed:@"facebook.png"];
UIButton *face = [UIButton buttonWithType:UIButtonTypeCustom];
face.bounds = CGRectMake( 0, 0, faceImage.size.width, faceImage.size.height );
[face setImage:faceImage forState:UIControlStateNormal];
UIBarButtonItem *faceBtn = [[UIBarButtonItem alloc] initWithCustomView:face];

我想这会对你有帮助

UIImage* topImage = [UIImage imageNamed:@"TabBarGradient.png"];

// Create a new image context
UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, topImage.size.height*2), NO, 0.0);

// Create a stretchable image for the top of the background and draw it
UIImage* stretchedTopImage = [topImage stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[stretchedTopImage drawInRect:CGRectMake(0, 0, width, topImage.size.height)];

// Draw a solid black color for the bottom of the background
[[UIColor blackColor] set];
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, topImage.size.height, width, topImage.size.height));

// Generate a new image
UIImage* resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return resultImage;
要了解更多详细信息,您可以查看此


如果没有解决您的问题..请告诉我..

如果它是正常的UIBarButtonItem,它将正常工作,但对UIBarButtonItem的灵活空格按钮不起作用。当然,我会尝试让您知道。