【发布时间】:2018-11-02 21:55:27
【问题描述】:
将 xcode 更新到 9.3,我的可编程按钮有问题
在 Xcode 8 中,我通过以下方式获得它并且效果很好
UIButton *btnSettingsButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
[btnSettingsButton setBackgroundImage:[UIImage imageNamed:@"settings.png"] forState:UIControlStateNormal];
[btnSettingsButton addTarget:self action:@selector(setttingsDashboard:) forControlEvents:UIControlEventTouchUpInside];
[btnSettingsButton setShowsTouchWhenHighlighted:YES];
UIBarButtonItem *btnSettingsItem =[[UIBarButtonItem alloc] initWithCustomView:btnSettingsButton];
屏幕 Xcode 8 enter image description here
按钮的图像“settings.png”很好地显示了我,高度为 25,宽度为 25。
但是当我开始使用 xcode 9 时,它并没有采用 initWithFrame: CGRectMake 并且它变得更大。 "按钮图片的大小
屏幕 Xcode 9.3 enter image description here
我该如何解决这个问题?
【问题讨论】:
-
settings.png 大小是什么
-
settings.png 的大小为 50 X 50
-
尽量做到 25x25,因为按钮已拉伸到它的大小
-
并且按钮无法保持我给它的大小?并且图像保持按钮的大小?
标签: ios objective-c iphone uibutton xcode9.3