我正在玩Swift,突然間什麼都沒有出現。Swift - UIView addConstraints不起作用
override func viewDidLoad() {
super.viewDidLoad()
var DiabolicView: UIView = UIView();//With UIButton it's working
DiabolicView.setTranslatesAutoresizingMaskIntoConstraints(false);
DiabolicView.frame.size = CGSize(width: 67, height: 67)
DiabolicView.backgroundColor = UIColor.redColor();//To see the view
view.addSubview(DiabolicView);
view.addConstraints([NSLayoutConstraint(item: DiabolicView,
attribute: .Bottom,
relatedBy: .Equal,
toItem: view,
attribute: .Bottom,
multiplier: 1.0,
constant: -100
)]);
}
是的,真的沒什麼(screen of nothing)
但是當我通過一個很酷的的UIButton更換惡魔的UIView,則紅場出現:
Screen of the magic Red Square when I replace UIView by UIButton
所以,問題是,爲什麼我看不到UIView?
感謝提前:)
超酷謝謝:):d – 2014-10-19 19:55:01