Vertical text in a Horizontal UIButton(水平 UIButton 中的垂直文本)
问题描述
我在纵向应用程序中使用垂直 UIButton(只是一个宽度为 60 和高度为 160 的普通按钮)
I'm using a vertical UIButton in a portrait app (Just a normal button that is of width 60 and Height 160)
我想将标签 Vetically 放在按钮下方,而不是放在按钮上方.
I want to put the label Vetically down the button instead of across it.
当我使用以下代码旋转标签时
When I use the following code to rotate the label
[workPackageButton.titleLabel setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
它会旋转标签,但长度似乎受到原始宽度的限制,所以我在中间得到了 ... 缩写.有没有简单的方法解决这个问题?
It rotates the label but the length seems to be constrained by the original width, so I get the ... abreviation in the middle. Is there an easy way round this?
推荐答案
您可以在按钮上添加标签并旋转标签,如下所示:
You can add a Label on button and rotate the label as below:
UILabel *lbl= [[UILabel alloc] initWithFrame:CGRectMake(button.frame.size.width*.3, button.frame.size.height*.5, button.frame.size.width,button.frame.size.height)];
lbl.transform = CGAffineTransformMakeRotation(M_PI / 2);
lbl.textColor =[UIColor whiteColor];
lbl.backgroundColor =[UIColor clearColor];
[button addSubview:lbl];
这篇关于水平 UIButton 中的垂直文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:水平 UIButton 中的垂直文本


基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01