简体   繁体   中英

uibutton.setTitle change text without changing font size

First, I added a button and set it's size to be 40

Then, in ViewController, I will change its text when user tap the button

startStopBtn.setTitle("START", for: .normal)

But not only the title change, the size also changed to 17.

Why is that? I want to keep the size unchanged.

Im using swift 5

在此处输入图像描述

在此处输入图像描述

iOS 15 introduced Configuration settings for many controls -- including UIButton .

When you create a button using Storyboard / Interface Builder in Xcode 13, the default configuration is Plain . Without changing that, you need to use the options via UIButton.Configuration to change much (most) of the button's appearance.

Selecting Default from the Button Style drop-down gives you a "pre-iOS 15" type of button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM