swift設置圓角

代碼中實現

view.layer.cornerRadius = 2 //圓角弧度
view.layer.masksToBounds = true  //是否把圓角邊切去

view.layer.borderWidth = 1   //設置邊框 的寬度 

view.layer.borderColor = UIColor.redColor.CGColor  //設置邊框的顏色


在xib中實現

點擊User Defined Runtime Attributes  的➕號

設置弧度

Key Path  : layer.cornerRadius

Type         : Number

Value        : 2

切去圓角

Key Path  : layer.masksToBounds

Type         : Boolean

Value        : ☑️



發佈了32 篇原創文章 · 獲贊 0 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章