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 中的垂直文本
基础教程推荐
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
