2016-03-21 5 views

Antwort

1

-Ansicht Da Ihre Frage ist nicht ganz klar fallen lassen, ich würde nur dieses:

YOURVIEW.addSubview(YOURBUTTON) 

iOS 9+

YOURVIEW.addSubview(YOURBUTTON) 

YOURBUTTON.translatesAutoresizingMaskIntoConstraints = false 
YOURBUTTON.topAnchor.constraintEqualToAnchor(YOURVIEW.topAnchor).active = true 
YOURBUTTON.bottomAnchor.constraintEqualToAnchor(YOURVIEW.bottomAnchor).active = true 
YOURBUTTON.leadingAnchor.constraintEqualToAnchor(YOURVIEW.leadingAnchor).active = true  
YOURBUTTON.trailingAnchor.constraintEqualToAnchor(YOURVIEW.trailingAnchor).active = true 

iOS 6+

let view = ["yourButotn": YOURBUTTON] 
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[yourButotn]-|", options: [], metrics: nil, views: views)) 
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[yourButotn]-|", options: [], metrics: nil, views: views)) 

dies die Einschränkungen

+0

dies ist nicht verfügbar in ios8 oder 7 es ist nur für ios9 –

+0

gut die Frage nicht die iOS-Version –

Verwandte Themen