【发布时间】:2016-02-29 22:58:38
【问题描述】:
我想添加一个自定义 UIView。我的自定义视图的类定义是:
class UserCoinView: UIView {
@IBOutlet weak var userName: UILabel!
@IBOutlet weak var coinView: UIView!
@IBOutlet weak var coinAmount: UILabel!
@IBOutlet weak var coinIcon: UILabel!
override func drawRect(rect: CGRect) {
let smartCoins = SmartShopperUtil.getSmartShopper().smartCoins
if smartCoins != nil && smartCoins >= 0 {
coinAmount.text = String(smartCoins!)
coinView.backgroundColor = SmartShopperUtil.getSmartCoinBackgroundColor(SmartShopperUtil.getSmartShopper().smartCoins!)
}
userName.text = SmartShopperUtil.getSmartShopperNameWithFullName(SmartShopperUtil.getSmartShopper().name)
coinIcon.text = AEVIcons.AEV_SMART_COIN
}
}
我在ViewController中添加了一个View 我要添加这个视图,并且我已经设置了这个视图的自定义类为UserCoinView。之后,我与 ViewController 建立了连接,在这个 ViewController 中我不知道要做什么才能显示我的自定义 UIView。
提前感谢您的帮助。
【问题讨论】: