일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- swift 문자
- 스위프트 UserDefaults
- 안드로이드 바로가기
- Flutter NativeView
- 스위프트
- 스위프트 푸시
- 안드로이드 앨범
- 안드로이드 에러
- 안드로이드 숏컷
- flutter rotate
- 안드로이드 FCM
- Flutter UIKitView MethodChannel
- Swift flutterview
- 플러터 뷰 컨트롤러
- 스위프트 앨범
- Swift flutterviewcontroller
- silent push
- flutter 회전
- FlutterView MethodChannel
- 노티피케이션 익스텐션
- 스위프트 웹뷰
- swift autolayout
- 앱 꺼졌을 때 푸시 데이터 저장
- 스위프트 테이블 뷰 셀
- swift sms
- 푸시 데이터 저장
- native flutter view
- 스위프트 카메라
- 앱 백그라운드 푸시 데이터 저장
- NotificationService Extension
- Today
- Total
Things take time
[SWIFT] 오토레이아웃 코드로 본문
[Code]
containerView = UIView(frame: self.view.frame) self.view.addSubview(containerView) //제약조건을 프로그래밍으로 할때는 뷰 자체적으로 수행하는 오토리사이징을 꺼야 함(이유 : 사용자가 지정한 오토레이아웃 조건과 충돌하여 제약조건 문제를 일으킴) containerView.translatesAutoresizingMaskIntoConstraints = false self.view.addConstraint(NSLayoutConstraint(item: containerView, attribute: .top, relatedBy: .equal, toItem: self.topLayoutGuide, attribute: .bottom, multiplier: 1, constant: 0)) self.view.addConstraint(NSLayoutConstraint(item: containerView, attribute: .bottom,relatedBy: .equal, toItem: self.bottomLayoutGuide, attribute: .bottom, multiplier: 1, constant: 0)) self.view.addConstraint(NSLayoutConstraint(item: containerView, attribute: .left ,relatedBy: .equal, toItem: self.view, attribute: .left , multiplier: 1, constant: 0)) self.view.addConstraint(NSLayoutConstraint(item: containerView, attribute: .right ,relatedBy: .equal, toItem: self.view, attribute: .right , multiplier: 1, constant: 0))
일단 뷰에 addSubView로 추가를 하고 이후에 코드로 작성할 것
위의 코드는 소스를 보면 알겠지만 화면의 크기에 맞춰 뷰를 늘린 것, topLayoutGuide까지 해야 상태바 밑으로 나오게 됨
[추가]
특정 뷰에 대비하여 제약조건을 걸 때는 위의 코드이나, 현재 하나의 뷰의 너비, 높이만 조절하고싶다면 아래와 같이 작성한다.
NSLayoutConstraint(item: ivMedia, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: size.height)
'iOS (기능)' 카테고리의 다른 글
[SWIFT] 스크롤할 때, 하단의 탭바 숨기기(보이기) (0) | 2017.10.30 |
---|---|
[SWIFT] UITbableView Header, 테이블 뷰 헤더 추가 및 고정 해제 방법, 헤더 구분선(Seperator)추가 (0) | 2017.10.27 |
[SWIFT] UITableView의 클릭 이벤트, 배경색상 없애기 (0) | 2017.09.18 |
[Xcode] 패키지를 새로운 프로젝트로 복사하기 (0) | 2017.09.13 |
[Xcode] SVN 사용하기 (0) | 2017.09.06 |