iOS/iOS Swift 개발 일기

iOS swift UIButtonConfiguration

Developer-Michelle 2022. 9. 30. 16:50

iOS swift UIButtonConfiguration

 

iOS 15+ 부터 새로 생김

버튼안에 이미지(아이콘) + title 같이 넣고 싶은 경우 참조! 진짜 잘 쓴 글

 

디자이너로부터 받은 이미지 크기가 일정하지 않아서 어떤건 크고 어떤건 작았으나, (때로는 24x24, 48x48)...등

아래 글을 보고 이미지 크기를 동일하게 만들 수 있었다.

 

내 경우 앱런칭 프로젝트에서 MemoVC -> 버튼들 참조

 

 lazy var othersBtn: UIButton = {

        let view = UIButton()

 

        var config = UIButton.Configuration.filled()

        config.title = "기타"

        config.baseForegroundColor = UIColor.black

        config.image = UIImage(named: "others")

        config.imagePadding = 4

        config.baseBackgroundColor = UIColor(rgb: 0xE4E8EB)

        config.contentInsets = NSDirectionalEdgeInsets.init(top: 4, leading: 4, bottom: 4, trailing: 4)

        view.configuration = config

 

        view.imageView?.contentMode = .scaleToFill

        view.titleLabel?.font =  UIFont(name: "Times New Roman", size: 15)

        return view

    }()

 

 

https://gyuios.tistory.com/126

 

iOS) UIButton.Configuration in iOS 15

iOS 15 에서 UIButton 에 새로생긴 UIButton.Configuration 에 대해서 알아보자! 먼저, 개발자문서를 따라가면서 버튼을 만드는 방법에 대해서 알아보자. Creating Buttons ✨ init(frame: CGRect) Creates a new..

gyuios.tistory.com

 

Button Image넣었을 때 크게

 

https://intrepidgeeks.com/tutorial/ios-use-sfsymbol-to-resize-the-button-of-the-specified-ui-image

 

[iOS] - SFSymbol로 UIImage를 지정한 Button의 사이즈 조절하기

UIButton의 이미지를 UIImage(systemName:)에서 SFsymbol을 사용하는 경우 해당 UIButton의 width나 height를 특정 상수 값으로 설정하더라도 버튼 이미지의 크기가 원하는 대로 보여지지 않는 경우가 있습니다.

intrepidgeeks.com

 

https://dominoc925.blogspot.com/2016/01/ios-uibuttons-image-aspect-fit-mode.html