이런 식으로 뭔가. 스토리 보드에서는 불가능하며 시도하지도 않습니다.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let layout = UICollectionViewFlowLayout()
UINavigationBar.appearance().barTintColor = UIColor.yellow
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
application.statusBarStyle = .lightContent
let textViewOne = UITextView()
textViewOne.text = "1000"
window?.addSubview(textViewOne)
//top constraint
window?.addConstraintsWithFormat("H:[v0(100)]-16-|", views: textViewOne)
window?.addConstraintsWithFormat("V:|-16-[v0(24)]", views: textViewOne)
return true
}
extension UIView {
func addConstraintsWithFormat(_ format: String, views: UIView...) {
var viewsDictionary = [String: UIView]()
for (index, view) in views.enumerated() {
let key = "v\(index)"
view.translatesAutoresizingMaskIntoConstraints = false
viewsDictionary[key] = view
}
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: format, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDictionary))
}
}
지금까지 해보신 것은 무엇입니까? – picciano