-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] UITextField 익스텐션 메서드 수정 #160
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
WalkthroughThe changes refactor the way Changes
Sequence Diagram(s)sequenceDiagram
participant PR as ProfileRegisterView
participant TF as UITextField
PR->>TF: init(pretendard: .body2, placeholder: "예) 중꺾마")
TF->>TF: Set defaultTextAttributes (font, kerning)
TF-->>PR: Return configured UITextField
Assessment against linked issues
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
Wable-iOS/Presentation/Helper/Extension/UITextField+.swift (1)
31-58: Well-designed convenience initializer that properly respects attribute precedenceThis implementation correctly addresses the issue mentioned in the PR by setting font attributes first, then applying other properties. A few observations:
- The initializer properly handles optional parameters with default values
- Correctly uses the same attributes for both the text and placeholder
- Sets both
defaultTextAttributesandfontproperties to ensure consistencyFor even more robustness, consider adding a check to ensure text alignment is preserved:
// 중요: defaultTextAttributes를 가장 먼저 설정하여 다른 속성들이 이를 덮어씌우지 않도록 함 self.defaultTextAttributes = defaultAttributes self.font = font + + // 텍스트 정렬 설정 보존 + self.textAlignment = self.textAlignmentThis ensures that if the default text alignment was changed before initialization, it won't be reset.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Wable-iOS/Presentation/Helper/Extension/UITextField+.swift(1 hunks)Wable-iOS/Presentation/Onboarding/View/ProfileRegisterView.swift(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
Wable-iOS/Presentation/Helper/Extension/UITextField+.swift (1)
Wable-iOS/Presentation/Helper/Extension/UIFont+.swift (1)
pretendard(93-95)
🔇 Additional comments (2)
Wable-iOS/Presentation/Onboarding/View/ProfileRegisterView.swift (1)
42-45: Good refactoring to use the new convenience initializerThe updated code uses the new
UITextFieldconvenience initializer that accepts Pretendard style and placeholder parameters directly. This approach is more concise and prevents potential issues where setting properties after initialization might overwrite font settings.Wable-iOS/Presentation/Helper/Extension/UITextField+.swift (1)
12-30: Excellent documentation with detailed explanations and examplesThe documentation clearly explains the purpose of the initializer, why it sets
defaultTextAttributesfirst (to prevent other properties from overwriting font settings), and provides useful examples. This level of detail is valuable for other developers using this API.
youz2me
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.
헉 저도 마침 UITextView 문제로 골머리를 좀 썩였는데 ... 초기화 시에 이렇게 설정해주면 좀 더 간편하게 접근할 수 있겠네요! 저도 사용할 곳이 있다면 유용하게 사용해보겠습니닷 ㅎㅎ
[Fix] UITextField 익스텐션 메서드 수정
👻 PULL REQUEST
📄 작업 내용
setPretendard(with:)를 삭제하고, 편의 생성자를 구현하였습니다.💻 주요 코드 설명
왜 편의생성자인가
UITextField의setPretendard(with:)을 통한defaultTextAttributes를 설정할 때의 문제를 해결하기 위함입니다.😂
setPretendard(with:)의 문제textColor = .blue)한 후,setPretendard(with:)를 호출하여,defaultTextAttributes를 설정하면 이전에 설정한 속성을 덮어씌워버리는 문제가 발생했습니다.😄 편의 생성자로
defaultTextAttributes의 설정 시점을 강제defaultTextAttributes를 먼저 설정하여, 이후 속성 설정이 덮어씌워지는 문제가 없도록 하였습니다.📍 왜
kerning만 적용했나요?lineHeight와baselineOffset은 불필요하다고 생각하였습니다.UITextField+.swift
🔗 연결된 이슈
Summary by CodeRabbit
New Features
Refactor