Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@IBDesignable와 @IBInspectable는 무엇? #96

Closed
Youngminah opened this issue Dec 13, 2021 · 0 comments
Closed

@IBDesignable와 @IBInspectable는 무엇? #96

Youngminah opened this issue Dec 13, 2021 · 0 comments
Labels

Comments

@Youngminah
Copy link
Owner

IBInspectable

image

  • Inspector와 관련이 있다고 보면 된다
  • 런타임에 속성이 결정된다.
class CustomView: UIView {

   @IBInspectable var borderWidth: CGFloat {
        get {  return layer.borderWidth }
        set {  layer.borderWidth = newValue }
    }
}

image

  • Border Witdh가 인스펙터 영역에 추가되었다
  • inspector에서 해당 인터페이스 요소의 속성을 변경할 수 있게 하는 것이 IBInspectable이다.
  • 저기서 값을 변경하는 것이 바로 "set연산"이 되는것
  • 여기까지만 설정하면 스토리보드에서 바로바로 즉각적인 확인은 아직 안되는 상태이다.

IBDesignable로 바로바로 업데이트를 확인하자

  • 컴파일 타임에서 (=실시간) 으로 확인이 가능하게 하는것
@IBDesignable
class CustomView: UIView {

   @IBInspectable var borderWidth: CGFloat {
        get {  return layer.borderWidth }
        set {  layer.borderWidth = newValue }
    }
}

image

  • IBDesignable를 설정해줌으로써 바로바로 확인이 가능하다
@Youngminah Youngminah added the iOS label Dec 13, 2021
@Youngminah Youngminah changed the title @IBDesignable / @IBInspectable @IBDesignable와 @IBInspectable는 무엇? Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant