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

iOS 15 Button #9

Closed
Youngminah opened this issue Sep 28, 2021 · 1 comment
Closed

iOS 15 Button #9

Youngminah opened this issue Sep 28, 2021 · 1 comment
Labels

Comments

@Youngminah
Copy link
Owner

Youngminah commented Sep 28, 2021

iOS 15 Button

image

바뀐점

  • Plain, Gary, Tinted, Filled 스타일의 버튼이 추가되었습니다.
  • multiline text가 지원됩니다.
  • Dynamic Type을 기본적으로 지원합니다.
  • subtitle을 지원
  • activity indicator를 지원

주의

  • isHighlighted는 UIButton의 State이므로 해당 값이 변경될 때 ConfigurationUpdateHandler가 호출됩니다.

Pop Up Button

image
애플개발자 참고문서

예제로 직접 구현해보기

class ButtonViewController: UIViewController {
    
    let button = UIButton()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        button.frame = CGRect(x: 0, y: 0, width: 300, height: 50)
        button.center = view.center
        button.configurationUpdateHandler = { btn in
            if btn.isHighlighted {
                btn.configuration?.baseBackgroundColor = .systemMint
                btn.configuration?.showsActivityIndicator = false
            }
        }
        button.configuration = .jackStyle()
        button.addTarget(self, action: #selector(buttonTap3), for: .touchUpInside)
        view.addSubview(button)
        
    }
}


@available(iOS 15.0, *)
extension UIButton.Configuration {
    
    static func jackStyle() -> UIButton.Configuration {
        var configuration = UIButton.Configuration.filled()
        configuration.title = "SeSAC"
        configuration.subtitle = "로그인 없이 둘러보기"
        configuration.titleAlignment = .center
        configuration.image = UIImage(systemName: "star.fill")
        configuration.baseForegroundColor = .white   //글씨체 색
        configuration.baseBackgroundColor = .systemPink //배경 색
        configuration.imagePadding = 8
        configuration.imagePlacement = .trailing
        configuration.cornerStyle = .capsule
        configuration.showsActivityIndicator = true
        return configuration
    }
    
}

image

@Youngminah
Copy link
Owner Author

  • 버튼에 텍스트와 이미지를 같이 추가하는 부분에서 불편했던 부분들이 크게 개선되었고
  • 버튼의 종류가 굉장히 다양해져 효율을 높힐 것 같다.

@Youngminah Youngminah changed the title Button (iOS 15) iOS 15 Button Jan 13, 2022
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