You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NavigationController에 .pushViewController 함수로 VC를 추가할 때 왜 첫VC에는 background color가 default로 white이고 두번째 VC 는 color가 없는 것인가요?
첫번째 VC 는 navigation controller가 뒤에 있어서 navigation Controller의 background가 white인게 그대로 투과되어서 보이는 것이고, 두번 째 VC는 그 밑에 첫번째 VC가 깔려있어서 background가 없는게 되는 것인가요?
코드
import UIKit
classMainViewController:UIViewController{privateletbutton=UIButton()overridefunc viewDidLoad(){
super.viewDidLoad()
// Do any additional setup after loading the view.
title ="Waffle"
//view.backgroundColor = .white
setButton()print(navigationController ??"No navigationController")}func setButton(){
view.addSubview(button)
button.setTitle("Press for adding Congroller", for:.normal)
button.setTitleColor(.systemOrange, for:.normal)
button.frame =CGRect(x:100, y:200, width:300, height:52)
button.addTarget(self, action: #selector(didTapButton), for:.touchUpInside)}@objcprivatefunc didTapButton(){letvc=MainViewController()print("adding vc to nc")
navigationController?.pushViewController(vc, animated:true)}}
The text was updated successfully, but these errors were encountered:
저도 이건 왜 발생하는지 정확히 모르겠네요 ㅎㅎ...
아마 view hierarchy를 확인해보면 나올 것 같기는 한데....
일단 전에 진섭이형이 설명했듯이 navigation Controller는 자체의 뷰는 의미가 없고 그 아이가 들고있는 뷰가 실질적인 디자인을 맡아야합니다. 그래서 애시당초 저렇게 아무것도 세팅 안하고 그냥 push 하면 뷰컨트롤러가 뷰를 컨트롤안하고 있는거니 어폐가 있는게 맞아요
그래서 navigationController는 navigationBar 디자인 제외하고는 보통 그냥 background color를 clear로 둡니다
요약
NavigationController에 .pushViewController 함수로 VC를 추가할 때 왜 첫VC에는 background color가 default로 white이고 두번째 VC 는 color가 없는 것인가요?
첫번째 VC 는 navigation controller가 뒤에 있어서 navigation Controller의 background가 white인게 그대로 투과되어서 보이는 것이고, 두번 째 VC는 그 밑에 첫번째 VC가 깔려있어서 background가 없는게 되는 것인가요?
코드
The text was updated successfully, but these errors were encountered: