
Swift에서 UIView의 크기를 얻어내는 방법은 `bounds` 프로퍼티를 사용하는 것입니다.
#hostingforum.kr
swift
let view = UIView()
let size = view.bounds.size
print(size.width, size.height)
또는 `frame` 프로퍼티를 사용하는 방법도 있습니다.
#hostingforum.kr
swift
let view = UIView()
let size = view.frame.size
print(size.width, size.height)
`UISize::of`는 Objective-C의 `UIEdgeInsetsMake` 함수와 유사한 `UIEdgeInsets` 클래스의 `init` 메서드에 사용되는 이름입니다.
#hostingforum.kr
swift
let insets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
이 메서드는 `UIEdgeInsets` 클래스의 인스턴스를 생성하는 데 사용됩니다.
Swift에서 `UIEdgeInsets` 클래스는 `UIEdgeInsets` struct로 대체되었습니다.
#hostingforum.kr
swift
let insets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
이 struct는 `top`, `left`, `bottom`, `right` 프로퍼티를 사용하여 인스턴스를 생성할 수 있습니다.
#hostingforum.kr
swift
let insets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
print(insets.top, insets.left, insets.bottom, insets.right)
`UIEdgeInsets` struct는 `width` 프로퍼티를 사용하여 두 가로边缘의 합을 계산할 수 있습니다.
#hostingforum.kr
swift
let insets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
print(insets.width)
`UIEdgeInsets` struct는 `height` 프로퍼티를 사용하여 두 세로边缘의 합을 계산할 수 있습니다.
#hostingforum.kr
swift
let insets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
print(insets.height)
2025-03-17 04:41