我在swift中创建我的UILabel:
let label = UILabel(frame: CGRect( x: 50, y: 50, width: 100, height: 50))
设置属性似乎很简单:
label.textColor = UIColor.redColor()
如何实现像textAlignment这样的枚举类型?在目标C中,
label.textAlignment = NSTextAlignmentCenter;
但在swift中,它似乎不起作用。
发布于 2014-06-04 18:02:39
Swift中的枚举与Objective-C中的枚举不同。
在Objective-C中的NSTextAlignmentCenter
是在Swift NSTextAlignment.Center
中。
发布于 2015-02-21 13:34:37
中心使用,myLabel.textAlignment = NSTextAlignment.Center
https://stackoverflow.com/questions/24034300
复制相似问题