我正在玩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