-
UIViewController의 view는 frame이 왜 변하지 않는것일까?앱등이에게 살충제를 뿌린다./고무망치를 도와라 2016. 6. 22. 18:10
1. viewDidLoad에서 self.view의 frame 변경
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters// // ViewController.swift // selfViewChange // import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.changeFrmae() } override func viewWillLayoutSubviews() { // self.changeFrmae() } func changeFrmae() { self.view.frame = CGRectMake(0, 100, CGRectGetWidth(self.view.frame), 300) self.view.layer.borderColor = UIColor.redColor().CGColor self.view.layer.borderWidth = 1.0 } } 변하질 않음
2. 그래서 viewWillLayoutSubviews에서 시도함
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters// // ViewController.swift // selfViewChange // import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.changeFrmae() } override func viewWillLayoutSubviews() { self.changeFrmae() } func changeFrmae() { self.view.frame = CGRectMake(0, 100, CGRectGetWidth(self.view.frame), 300) self.view.layer.borderColor = UIColor.redColor().CGColor self.view.layer.borderWidth = 1.0 } } 잘됨.
viewDidLoad에서 안되는걸 보니 runtime에서 동적으로 frame을 바꾸는건 불가능한가?
불가능한것인가? 안되는건가?
도와주세요.
'앱등이에게 살충제를 뿌린다. > 고무망치를 도와라' 카테고리의 다른 글
Duplicate Symbol이나 link warning이 발생하지 않는다. (0) 2018.06.11 Swift에서는 왜 Import 헤더를 하지 않아도 되는 것일까? (0) 2016.12.28 [iOS/GCD] dispatch_async, dispatch_sync (6) 2016.11.12 [iOS] UICollectionView에서 발생하는 크래쉬 (1) 2016.07.29