我是新的快速编程,我试图制作一个钢琴应用程序。有谁知道豪特在Swift中的按钮边框? 我在互联网上搜索,但所有的教程都是针对老版本的Swift,它不再工作。快速按钮的轮廓
Q
快速按钮的轮廓
-3
A
回答
0
尝试这个
button.layer.borderWidth = 1.0
button.layer.borderColor = UIColor.whiteColor().CGColor
button.layer.cornerRadius = 5.0
button.clipsToBounds = true
您可以轻松地更改按钮属性,如(边框宽度,边框颜色,cornerRadius)值
-1
这里是SWIFT 3
button.layer.borderWidth = 1.0
button.layer.borderColor = UIColor.white.cgColor
// if you want corners to be rounded you can use the corner radus
button.layer.cornerRadius = 4.0
// if you're setting background image to the button and it happens to be not clipped then you can use
button.clipsToBounds = true
0
的UIButton继承的代码UIControl和UIControl从 继承UIView。 UIView包含用于渲染的CALayer(核心动画层)。 https://developer.apple.com/reference/quartzcore/calayer
import UIKit
import PlaygroundSupport
let button = UIButton(type: .custom)
button.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
button.backgroundColor = .red
button.layer.borderWidth = 2.0
button.layer.borderColor = UIColor.green.cgColor
PlaygroundPage.current.liveView = button
相关问题
- 1. 按钮轮廓大于按钮尺寸
- 2. HTML中的弯曲按钮轮廓CSS
- 3. 如何删除html按钮的轮廓
- 4. Safari中的奇怪按钮轮廓
- 5. 删除引导4按钮轮廓Mixin
- 6. 移除CSS按钮轮廓即6.0,7.0
- 7. 如何隐藏按钮轮廓
- 8. Matlab中的快速DP(用于轮廓HMM的维特比)
- 9. 存储按钮按快速
- 10. 快速AVAudioplayer上按钮按
- 11. 后退按钮与按钮轮廓出现
- 12. 轮廓轮廓着色器
- 13. OpenCV/numpy:使用numpy快速比较大量轮廓对象
- 14. Split SpatialLinesDataFrame轮廓按级别
- 15. 搜索轮廓内的轮廓/ OpenCV C++
- 16. 快速按钮显示
- 17. 快速按钮变灰
- 18. PayPal快速结账按钮
- 19. 防止快速按钮砸
- 20. 快速按钮阵列
- 21. 从轮廓中提取最外轮廓
- 22. 轮廓匹配 - 找到轮廓位移
- 23. 绘制轮廓后找到轮廓
- 24. 为什么我的按钮有这个轮廓? css
- 25. 在所有未选中的单选按钮上显示轮廓
- 26. 删除按钮上的蓝色“选定”轮廓
- 27. 如何摆脱我按钮周围的白色轮廓?
- 28. jquery摆脱按钮周围的虚线轮廓
- 29. Xml:笔划,边框,按钮内部的轮廓文本
- 30. 带虚线轮廓的按钮 - 9patch with tileMode =“重复”?
请搜索。在[这些搜索结果](http://stackoverflow.com/search?page=1&tab=Relevance&q=%5bswift%5d%20uibutton%20border)中的第一次击中应该工作。 – rmaddy