相关疑难解决方法(0)

如何调整rightBarButtonItems中两个UIBarButtonItem之间的空间

我使用以下代码将两个按钮添加到self.navigationItem.rightBarButtonItems,我认为在iOS7中,两个按钮之间的空间太宽,有没有办法减少这两个按钮之间的空间?

UIBarButtonItem *saveStyleButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"save.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(saveStyle)];

UIBarButtonItem *shareStyleButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareStyle)];

NSArray *arr= [[NSArray alloc] initWithObjects:shareStyleButton,saveStyleButton,nil];

self.navigationItem.rightBarButtonItems=arr;
Run Code Online (Sandbox Code Playgroud)

欣赏任何提示或想法.

iphone xcode spacing rightbarbuttonitem ios7

32
推荐指数
6
解决办法
3万
查看次数

iOS 11 UIBarButtonItem图像没有大小调整

我在这个问题中暗示了我的问题的答案,所以我认为答案是禁用我的UIToolbar视图的自动布局.

据说适用于视图的代码是

cButton.translatesAutoresizingMaskIntoConstraints = YES;
Run Code Online (Sandbox Code Playgroud)

但我不确定它是否适用于我的代码,因为UIToolbar不会从UIView继承.

我有很多小图像,我在游戏中使用不同大小,具体取决于设备和方向.当Apple推出新设备时,我决定先制作一张160x160的图像,然后在使用时调整大小,而不是拥有大量不同的图像,并添加新图像.这在iOS 4 - iOS 10中运行良好,但在iOS 11中失败.

代码非常简单:

// Get the image
NSString *pictFile = [[NSBundle mainBundle] pathForResource:@"Correct" ofType:@"png"];
UIImage *imageToDisplay = [UIImage imageWithContentsOfFile:pictFile];
UIImage *cImage  = [UIImage imageWithCGImage:imageToDisplay.CGImage scale:[UIScreen mainScreen].scale orientation:imageToDisplay.imageOrientation];

UIButton *cButton = [UIButton buttonWithType:UIButtonTypeCustom];
[cButton setImage:cImage forState:UIControlStateNormal];
[cButton setTitle:@"c" forState:UIControlStateNormal];

//set the frame of the button to the size of the image
cButton.frame = CGRectMake(0, 0, standardButtonSize.width, standardButtonSize.height);

//create a UIBarButtonItem with the button as a custom view
c = …
Run Code Online (Sandbox Code Playgroud)

uitabbar ios ios11

14
推荐指数
1
解决办法
7715
查看次数

标签 统计

ios ×1

ios11 ×1

ios7 ×1

iphone ×1

rightbarbuttonitem ×1

spacing ×1

uitabbar ×1

xcode ×1