-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#8] chipViewController 생성 #15
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
첫 이슈! 수고하셨습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다.
몇가지 추가되어야 할부분이 있는 것 같아요
- icon 추가
- 좌우 icon on/off 기능 추가
@Invalidating(wrappedValue: nil, .layout) public var text: String? { | ||
didSet { | ||
if let text = text, text.count > 10 { | ||
self.text = String(text.prefix(10)) | ||
} | ||
setNeedsLayout() | ||
} | ||
} | ||
|
||
@Invalidating(wrappedValue: nil, .layout) public var leftIcon: UIImage? | ||
@Invalidating(wrappedValue: nil, .layout) public var rightIcon: UIImage? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Invalidating
을 사용한 이유가 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Invalidating
을 통해 HandyChip의 text와 leftIcon, rightIcon 프로퍼티를 선언함으로서 HandyChip에서 해당 프로퍼티를 지정했을 때 HandyChip 레이아웃을 다시 그리도록 하기 위해 사용했습니다. 프로퍼티 값이 변경되었을 때 setNeedsLayout()
을 직접 호출하지 않아도 되어서 코드를 간결화할 수 있었습니다.
override func setViewHierarchies() { | ||
view.addSubview(unTappedLargeChip) | ||
view.addSubview(unTappedSmallChip) | ||
view.addSubview(tappedLargeChip) | ||
view.addSubview(tappedSmallChip) | ||
view.addSubview(disabledLargeChip) | ||
view.addSubview(disabledSmallChip) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override func setViewHierarchies() { | |
view.addSubview(unTappedLargeChip) | |
view.addSubview(unTappedSmallChip) | |
view.addSubview(tappedLargeChip) | |
view.addSubview(tappedSmallChip) | |
view.addSubview(disabledLargeChip) | |
view.addSubview(disabledSmallChip) | |
} | |
override func setViewHierarchies() { | |
[unTappedLargeChip, | |
unTappedSmallChip, | |
tappedLargeChip, | |
tappedSmallChip, | |
disabledLargeChip, | |
disabledSmallChip | |
].forEach { | |
view.addSubview($0) | |
} | |
} |
view.addSubviews(unTappedLargeChip, unTappedSmallChip, tappedLargeChip, tappedSmallChip, disabledLargeChip, disabledSmallChip) 이런식으로도 사용하실 수 있어요~
📌 Summary
✍️ Description
💡 PR Point
size
와 통일하여, chip의 상태를 지정할 때 변수의 이름을state
로 지정하고 싶었지만 UIControl에서 state를 사용중이어서chipState
로 지정하였습니다.📚 Reference
🔥 Test
사용방법