在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
创建模板类(封装一个类) 例1:
例2: override func viewDidLoad() { super.viewDidLoad() let circle = CircleView(frame: CGRectMake(100, 150, 150, 150)) self.view.addSubview(circle) self.addLabel(circle1.frame, text: "X", fontSize: 60) } func addLabel(frame: CGRect, text: String, fontSize: CGFloat) { let label = UILabel(frame: frame) label.text = text label.textAlignment = .Center label.font = UIFont.systemFontOfSize(fontSize, weight: 10) self.view.addSubview(label) }
|
请发表评论