简体   繁体   English

如何实用地增加按钮的字体大小(swift3)

[英]How to increase Font Size in button Pragmatically (swift3)

I would like the user to have the ability to make the text larger. 我希望用户能够使文本变大。

I have figured out how to increase a button overall size but the text remains the same. 我已经弄清楚了如何增加按钮的整体大小,但是文本保持不变。

button.frame =  CGRect(x: 100, y: 400, width: 100, height: 50)

How to increase Font Size in button Pragmatically in swift3? 如何在swift3中实用地增加按钮的字体大小?

Use titleLabel, like this: 使用titleLabel,如下所示:

let button = UIButton()
button.titleLabel?.font = UIFont.systemFont(ofSize: 30)

You can use UIFont in a lot of ways, check it's constructor! 您可以通过多种方式使用UIFont,请检查其构造函数!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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