我是新的快速編程,我試圖製作一個鋼琴應用程序。有誰知道豪特在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. HTML中的彎曲按鈕輪廓CSS
- 2. 移除CSS按鈕輪廓即6.0,7.0
- 3. 如何隱藏按鈕輪廓
- 4. 刪除引導4按鈕輪廓Mixin
- 5. 快速AVAudioplayer上按鈕按
- 6. 存儲按鈕按快速
- 7. 輪廓輪廓着色器
- 8. PayPal快速結賬按鈕
- 9. 快速按鈕顯示
- 10. 快速按鈕變灰
- 11. 從輪廓中提取最外輪廓
- 12. 輪廓匹配 - 找到輪廓位移
- 13. 繪製輪廓後找到輪廓
- 14. 爲什麼我的按鈕有這個輪廓? css
- 15. jquery擺脫按鈕周圍的虛線輪廓
- 16. Xml:筆劃,邊框,按鈕內部的輪廓文本
- 17. 在所有未選中的單選按鈕上顯示輪廓
- 18. 從Python中的二進制掩碼檢索輪廓掩碼的快速方法
- 19. Android中的快速搜索按鈕
- 20. 快速喜歡Tumblr上的按鈕
- 21. 處理按鈕上的快速點擊
- 22. 如何在按鈕輪廓上有顏色更改動畫?
- 23. 引導按鈕輪廓在點擊後保持高亮
- 24. 使按鈕背景輪廓在幾秒鐘後消失
- 25. 輪廓發現
- 26. 輪廓形狀
- 27. Opencv輪廓
- 28. 提取輪廓
- 29. OpenCV輪廓?
- 30. 輪廓提取
請搜索。在[這些搜索結果](http://stackoverflow.com/search?page=1&tab=Relevance&q=%5bswift%5d%20uibutton%20border)中的第一次擊中應該工作。 – rmaddy