티스토리 뷰
Frame 개념
Frame 은 상위 뷰 안에서의 현재 뷰의 위치라고 보면 되고, 우리가 쉽게 떠올리는 기본적이고 일반적인 개념이라고 보면 된다.
Frame 구현
이미지로 확인해보면 아래의 프래임 이미지는 아래와 같이 코딩하고 self.view 에 addSubview를 한 경우이다
testView.frame = CGRect(x: 40,y: 50,width: 50,height: 50)
Bounds 개념
Bounds는 카메라는 그대로 있고, 뷰 자체를 움직이고 싶을 때 사용한다.
scrollview의 경우 본문의 크기는 휴대폰의 화면 사이즈를 넘어가는 형태로 그대로 있는 것이고 카메라도 그대로인데 뷰가 위로 올라가거나 내려가는 것을 상상해 볼 수 있다.
아래의 그림을 보면 더 잘 이해할 수 있다.
Bounds 구현
이미지로 확인해보면 아래의 프래임 이미지는 아래와 같이 코딩하고 self.view 에 addSubview를 한 경우이다
//Bound Image Origin
testView.frame = CGRect(x: 40,y: 50,width: 200,height: 200)
testView.backgroundColor = UIColor.blue
smallView.frame = CGRect(x: 40,y: 50,width: 50,height: 50)
smallView.backgroundColor = UIColor.red
testView.addSubview(smallView)
//Bound Image Modified
testView.bounds = CGRect(x: 40,y: 50,width: 200,height: 200)
화면을 일자로 늘어놓고 스크롤하도록 하는 화면을 만들 때, 특정 위치에서 정지하려고 하면 아래와 같이 setContentOffset을 사용하고 이때, GCPoint(x, y) 자리에 들어가는 게 Bounds라고 보면 되겠다.
scrlView.setContentOffset(CGPoint(x,y), animated: NO)
'iOS' 카테고리의 다른 글
ios realm swift 기초 - 1 (0) | 2022.06.02 |
---|---|
lottie-ios quick start -1 (0) | 2022.05.08 |
In-Active State (0) | 2022.04.26 |
Swift Final Keyword (0) | 2022.04.25 |
Swift Retain Cycle (0) | 2022.04.25 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- ChatGPT
- ATS failed system trust
- GPT4
- 모듏화
- swiftLint
- xcode whitespace trim option
- GCD
- bitrise
- geohash
- jenkins
- firebase
- RxSwift
- 프로그래머스
- 같이쓰기
- 빌드자동화
- Moya
- 무료는 아니지만
- ios
- async
- 코테
- IF (KAKAO) DEV 2022
- Fastlane
- AppThinning
- XCTestExpectation
- CI/CD
- MQTT
- chatgpt 4o
- Default Rules
- AWS IoT
- swift
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함