gpt4 book ai didi

ios - 水平 UIButton 中的垂直文本

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:18:54 27 4
gpt4 key购买 nike

我在纵向应用程序中使用垂直 UIButton(只是一个宽度为 60,高度为 160 的普通按钮)

我想将标签垂直放置在按钮下方而不是横跨按钮。

当我使用下面的代码来旋转标签时

    [workPackageButton.titleLabel setTransform:CGAffineTransformMakeRotation(M_PI / 2)];

它旋转了标签,但长度似乎受到原始宽度的限制,所以我在中间得到了 ... 缩写。有解决这个问题的简单方法吗?

最佳答案

您可以在按钮上添加标签并旋转标签,如下所示:

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];

关于ios - 水平 UIButton 中的垂直文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13230567/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com