【发布时间】:2016-02-20 15:23:52
【问题描述】:
我想要一个“真正的”圆形 UIView,以避免应用角半径的方形视图。
因为我用的是重力,我的圆圈显示不好,因为在角落里不能互相接触(屏幕是从“Debug View Hierarchy”按钮看3D屏幕的:
我的圆形 UIView 的实际代码:
import Foundation
import UIKit
@IBDesignable class CircleView:UIView {
override init (frame : CGRect) {
super.init(frame : frame)
self.layer.cornerRadius = frame.width / 2
self.clipsToBounds = true
addBehavior()
}
convenience init () {
self.init(frame:CGRect(x: 0, y: 0, width: 50 , height: 50))
self.layer.cornerRadius = self.frame.width / 2
self.clipsToBounds = true
}
required init(coder aDecoder: NSCoder) {
fatalError("This class does not support NSCoding")
}
func addBehavior (){
//print("Add all the behavior here")
}
}
谢谢!!
【问题讨论】:
-
你试过用谷歌搜索 uikit 重力圈吗? ;)