-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] 프로필 편집 UI, 닉네임 유효성 로직 수정 / GlassBorder 리팩토링 (#164) #165
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
Conversation
cirtuare
left a comment
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.
논의가 길어져서 복잡했을 텐데 고생했어요💗!!!!!
| // MARK: - UI Properties | ||
|
|
||
| private let firstIcon = UIImageView() | ||
| private let icon = UIImageView() |
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.
🐿️
컨벤션에 따라 뒤에 -ImageView 붙여주시면 조금 더 보기 편할 것 같아요 !
| override func layoutSubviews() { | ||
| super.layoutSubviews() | ||
|
|
||
| if let glassBorderAttribute = glassBorderAttribute { | ||
| self.addGlassBorder(glassBorderAttribute) | ||
| } | ||
| } |
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.
🐿️
여기서 글모 백그라운드 뷰 리프레시는 필요없었나요?!
static으로 선언되어, 한 뷰에서 glassBorder를 사용하는 뷰가 2개 이상 있을 때 remove, refresh가 제대로 적용 안 되었음
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.
리뷰 반영했습니다~ @cirtuare
glassBorder도 새로고침이 필요한 걸 발견했는데,
기존 코드로는 한계가 있어서 UIView+ 메소드를 수정했습니다!
| //MARK: - GlassBorder 설정 | ||
|
|
||
| extension UIView { | ||
|
|
||
| private struct AssociatedKeys { | ||
| static var glassBorderView: UInt8 = 0 | ||
| } | ||
|
|
||
| private var glassBorderView: GlassmorphismView? { | ||
| get { | ||
| return objc_getAssociatedObject(self, &AssociatedKeys.glassBorderView) as? GlassmorphismView | ||
| } | ||
| set { | ||
| objc_setAssociatedObject(self, &AssociatedKeys.glassBorderView, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | ||
| } | ||
| } | ||
|
|
||
| /// 주의: bounds가 0이면 적용 안 됨 | ||
| func addGlassBorder(_ attributes: GlassBorderAttributes) { | ||
| self.layer.borderWidth = 0 | ||
|
|
||
| glassBorderView?.removeFromSuperview() | ||
|
|
||
| let outerPath = UIBezierPath(roundedRect: bounds, cornerRadius: attributes.cornerRadius) | ||
| let innerRect = bounds.insetBy(dx: attributes.width, dy: attributes.width) | ||
| let innerPath = UIBezierPath(roundedRect: innerRect, cornerRadius: max(0, attributes.cornerRadius - attributes.width/2)) | ||
| outerPath.append(innerPath.reversing()) | ||
|
|
||
| UIView.glassBorderView = GlassmorphismView(attributes.glassmorphismType) | ||
|
|
||
| self.addSubview(UIView.glassBorderView) | ||
| UIView.glassBorderView.snp.makeConstraints { | ||
|
|
||
| let newGlassBorderView = GlassmorphismView(attributes.glassmorphismType) | ||
| self.glassBorderView = newGlassBorderView | ||
|
|
||
| self.addSubview(newGlassBorderView) | ||
|
|
||
| newGlassBorderView.snp.makeConstraints { | ||
| $0.edges.equalToSuperview() | ||
| } | ||
|
|
||
| let maskLayer = CAShapeLayer() | ||
| maskLayer.path = outerPath.cgPath | ||
| maskLayer.fillRule = .evenOdd | ||
|
|
||
| let maskView = UIView(frame: bounds) | ||
| maskView.layer.addSublayer(maskLayer) | ||
| UIView.glassBorderView.mask = maskView | ||
| newGlassBorderView.mask = maskView | ||
|
|
||
| newGlassBorderView.isUserInteractionEnabled = false | ||
| } | ||
|
|
||
|
|
||
| func refreshGlassBorder() { | ||
| glassBorderView?.refreshBlurEffect() | ||
| } | ||
|
|
||
| func removeGlassBorder() { | ||
| UIView.glassBorderView.removeFromSuperview() | ||
| glassBorderView?.removeFromSuperview() | ||
| } |
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.
@cirtuare UIView+ GlassBorder 관련 추가 수정 사항 생겼습니다!
기존 코드에서는 glassBorder가 static으로 선언되어서 모든 뷰가 하나의 glassBorderView 인스턴스를 공유했습니다.
따라서 한 뷰에서 2개 이상의 glassBorder가 있을 때 UI 업데이트가 정상적으로 안 되는 문제가 있었습니다.
이에, Associated Object를 활용하여 각 뷰마다 고유한 glassBorderView 인스턴스를 가질 수 있도록 했습니다.
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.
최고 !!!
🐿️ Pull Requests
🪵 작업 브랜치
🥔 작업 내용
addGlassBorder메소드 오류 해결borderView가 user interaction을 가로채는 문제를 해결했습니다.
ACTextField글래스모피즘용 이니셜라이저를 구현->
업로드뷰 SearchTextField,프로필편집뷰 TextField에 적용프로필 편집 관련
📸 스크린샷
💥 To be sure
🌰 Resolve issue