longlivedrgn
Miro 찾기
longlivedrgn
전체 방문자
오늘
어제
  • 분류 전체보기 (74)
    • Swift (36)
    • iOS (31)
    • Algorithm (0)
    • Architecture, Design Patter.. (1)
    • Computer Science (6)
      • 컴퓨터 네트워크 (6)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
longlivedrgn

Miro 찾기

[iOS] CGPoint, CGSize, CGRect
iOS

[iOS] CGPoint, CGSize, CGRect

2023. 2. 6. 20:53

CGPoint, CGSize, CGRect

  • 기본적으로 view를 짜기위해서는 x,y 좌표가 필요하고, width, height가 필요하다.

from. 소들이님 블로그

CGPoint

  • View의 위치를 나타낼 때 사용한다
  • public struct CGPoint { public init() public init(x: Double, y: Double) public var x: Double public var y: Double }
  • 활용
  • let point: CGPoint = .init(x: 10, y: 20)

CGSize

  • (width, height) 사이즈를 설정할 때 사용한다
  • public struct CGSize { public init() public init(width: Double, height: Double) public var width: Double public var height: Double }
  • 활용
  • let size: CGSize = .init(width: 10, height: 20)

CGRect

  • CGPoint, CGSize를 한번에 설정할 때 사용한다.
  • public struct CGRect { public init() public init(origin: CGPoint, size: CGSize) public var origin: CGPoint public var size: CGSize }
  • 활용
  • let rect: CGRect = .init(x: 10, y: 20, width: 15, height: 20)

CGRect를 활용하여 View 정의

let rect: CGRect = .init(x: 10, y: 20, width: 15, height: 20)
let yourView: UIView = .init(frame: rect)
저작자표시 (새창열림)

'iOS' 카테고리의 다른 글

[iOS] Target-Action Pattern  (0) 2023.02.06
[iOS] UIResponder  (0) 2023.02.06
[iOS] TextField 왼쪽 여백 넣기  (0) 2023.02.06
[iOS] File System  (0) 2023.02.04
[iOS] MVC  (0) 2023.02.04
    'iOS' 카테고리의 다른 글
    • [iOS] Target-Action Pattern
    • [iOS] UIResponder
    • [iOS] TextField 왼쪽 여백 넣기
    • [iOS] File System
    longlivedrgn
    longlivedrgn

    티스토리툴바