UIButton标题标签转换切断了标签 [英] UIButton title label transform cuts off label

查看:158
本文介绍了UIButton标题标签转换切断了标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个UIButton,其界面构建器的宽度为30px,高度为164px。

I am creating a UIButton with interface builder of size 30px width and 164px height.

我想将UIButton的标题旋转到90度。

I want to rotate title of UIButton to 90 degrees.

我使用以下代码进行轮换

I am using following code for rotation

// leftNavBtn1 is a UIButton
self.leftNavBtn1.titleLabel.transform = CGAffineTransformMakeRotation(-M_PI / 2);

问题是轮换后标签被切断。我试图以编程方式设置标题,但它不起作用。

The problem is after rotation the label cuts off. I have tried to programatically set title but its not work.

我想实现这样的目标

我得到了什么

推荐答案

titleLabel 属性主要用于配置按钮的文本,而不是其边界。

The titleLabel property is primarily used to configure the text of the button, not its bounds.

我认为你无法实现你想要达到的目标。

如果我理解你的话,你会做一个宽度小而且大的按钮接口构建器中的高度,然后将按钮标签上的变换设置为90º,然后希望按钮的行为就像宽度变为高度一样,反之亦然。

I don't think you can achieve what you want to achieve.
If I understand you correctly, you make a button with a small width and big height in interface builder, then set the transformation on the label of the button to 90º, and then expect the button to behave as if the width became the height and vice versa.

我想您仍然可以在界面构建器中设置按钮,但是将其设置为水平,就像旋转-90º一样,然后设置反转中的UIButton形成viewDidLoad

I suppose you could still set the button in interface builder, but make it horizontal, as if it's rotated -90º, and then set the transformation on the UIButton in viewDidLoad

这篇关于UIButton标题标签转换切断了标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆