W.S*_*W.S 11 uibutton ios ios5
是否可以在不改变Button背景图像大小的情况下增加UIButton的可拍摄区域
我试过了:
[shareButton setContentEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
Run Code Online (Sandbox Code Playgroud)
&
[shareButton setImageEdgeInsets:UIEdgeInsetsMake(top, left, bottom, right)];
Run Code Online (Sandbox Code Playgroud)
但这些都没有奏效.
有什么建议吗?
W.S*_*W.S 14
制作类型的UIButton buttonWithType:UIButtonTypeCustom并为其分配较小尺寸的图像.
不要将图像设置为背景图像,否则它将随按钮一起增长.将其设置为主图像.
例如,如果要将可点击区域设置为64x64大小,并且要显示大小为32x32的图像:按钮大小应为64x64,图像大小应为32x32.
编程方式:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
// use an image with the desired size (for example 32x32)
[button setImage: [UIImage imageNamed: @"buttonIcon.png"] forState: UIControlStateNormal];
// just set the frame of the button (64x64)
[button setFrame: CGRectMake(xPositionOfMyButton, yPositionOfMyButton, 64, 64)];
Run Code Online (Sandbox Code Playgroud)
界面生成器:

| 归档时间: |
|
| 查看次数: |
13226 次 |
| 最近记录: |