Tho*_*mas 2 uibutton ios swift ios9 swift2
我给自己定一个transparent image作为background一个UIButton我使用。它看起来很完美,但是问题是transparent image它很小,因此用户在第一次尝试时很难正确地单击它。
这是我的代码:
optionsButton.setBackgroundImage(UIImage(named: "CalendarEventArrowIcon"), forState: UIControlState.Normal)
optionsButton.addTarget(self, action: "optionsButtonPressed", forControlEvents: UIControlEvents.TouchDown)
Run Code Online (Sandbox Code Playgroud)
有没有一种方法,我可以拿我使用的是当前的图像,并把它与一个更大的框架一个UIImage里面,然后使该按钮的背景图片programmatically的 Swift?
通过这样做,由于背景图像将占据较大的面积,因此将使用户更容易单击按钮。
还是我实际上要做的事情是这样的唯一方法,然后返回到Photoshop,使background image我使用的更大,而不再拥有它了transparent background?
您可以使用扩展按钮的可点击区域contentEdgeInsets。例如,要在按钮的所有侧面上添加15个填充点,请添加以下内容:
optionsButton.contentEdgeInsets = UIEdgeInsetsMake(15, 15, 15, 15)
| 归档时间: |
|
| 查看次数: |
1321 次 |
| 最近记录: |