[#285] iOS 18에서 adaptiveButtonStyle가 일부 잘려 보이는 현상을 해결한다#291
Conversation
opficdev
commented
Mar 17, 2026
- closed iOS 18에서 adaptiveButtonStyle가 일부 잘려 보이는 현상을 해결한다 #285
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 풀 리퀘스트는 iOS 18에서 adaptiveButtonStyle이 올바르게 렌더링되지 않아 일부가 잘려 보이는 문제를 해결합니다. adaptiveButtonStyle 함수의 shape 매개변수 타입을 InsettableShape로 구체화하고, 배경 및 테두리 렌더링 로직을 strokeBorder를 사용하여 개선함으로써, 다양한 도형의 버튼 스타일이 모든 iOS 버전에서 일관되고 정확하게 표시되도록 보장합니다. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이 PR은 iOS 18에서 adaptiveButtonStyle의 테두리가 잘려 보이는 문제를 해결하기 위해 .stroke를 .strokeBorder로 변경하는 것을 목표로 합니다. 이를 위해 함수의 shape 파라미터 타입을 some Shape에서 제네릭 InsettableShape으로 변경했습니다. 리뷰 결과, 제네릭 함수 시그니처의 기본값 설정과 .strokeBorder 적용 방식에서 컴파일 오류를 유발할 수 있는 두 가지 심각한 문제가 발견되어 수정을 제안했습니다.
| func adaptiveButtonStyle<S: InsettableShape>( | ||
| shape: S = Capsule(), | ||
| color: Color = .clear | ||
| ) -> some View { |
There was a problem hiding this comment.
제네릭 타입 S에 대해 Capsule()을 기본값으로 설정할 수 없습니다. S는 어떤 InsettableShape이든 될 수 있기 때문에 컴파일러가 타입을 추론할 수 없어 오류가 발생합니다.
가장 직접적인 수정은 아래와 같이 기본값을 제거하는 것입니다. 하지만 이 경우 기존 호출 코드에 영향을 줄 수 있습니다.
더 나은 해결책은 기본값을 사용하는 오버로드 함수를 추가하는 것입니다:
@ViewBuilder
func adaptiveButtonStyle(color: Color = .clear) -> some View {
self.adaptiveButtonStyle(shape: Capsule(), color: color)
}
// 그리고 이 함수의 시그니처를 아래와 같이 변경합니다.
@ViewBuilder
func adaptiveButtonStyle<S: InsettableShape>(
shape: S,
color: Color = .clear
) -> some View {
// ... implementation
}| func adaptiveButtonStyle<S: InsettableShape>( | |
| shape: S = Capsule(), | |
| color: Color = .clear | |
| ) -> some View { | |
| func adaptiveButtonStyle<S: InsettableShape>( | |
| shape: S, | |
| color: Color = .clear | |
| ) -> some View { |
| shape | ||
| .fill(color == .clear ? Color(.systemGray5) : color) | ||
| .strokeBorder(Color.white.opacity(0.2), lineWidth: 1) |
There was a problem hiding this comment.
.fill 메서드는 some View를 반환하므로 InsettableShape의 메서드인 .strokeBorder를 직접 체이닝할 수 없습니다. 이 코드는 컴파일되지 않습니다.
배경과 테두리를 함께 적용하려면 overlay 수정자를 사용하는 것이 좋습니다. 이렇게 하면 코드를 간결하게 유지하면서도 올바르게 테두리를 그릴 수 있습니다.
| shape | |
| .fill(color == .clear ? Color(.systemGray5) : color) | |
| .strokeBorder(Color.white.opacity(0.2), lineWidth: 1) | |
| shape | |
| .fill(color == .clear ? Color(.systemGray5) : color) | |
| .overlay(shape.strokeBorder(Color.white.opacity(0.2), lineWidth: 1)) |