ios - Xcode 中标签文本的对齐方式

标签 ios xcode

我想稍微移动标签中的文本。我已经通过在属性检查器中对齐将文本放在右边。但我想将它稍微向左移动。不确定要按什么按钮。我已经查看了属性检查器中的所有功能,但仍然找不到。

这是现在的样子:enter image description here

喜欢将零稍微向左移动一些。我该怎么做?

最佳答案

如果你想在标签内移动文本,你必须子类化 UILabel 并覆盖 drawTextInRect: 像这样:

@implementation RDLabel

- (void)drawTextInRect:(CGRect)rect {
    CGRect newRect = CGRectMake(0, 0, rect.size.width - 10, rect.size.height);
    [super drawTextInRect:newRect];
}
@end

如果文本右对齐,这会将文本向左移动 10 磅。

关于ios - Xcode 中标签文本的对齐方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13323694/

相关文章:

ios - Realm swift : passing unpersisted objects between threads

ios - 我为什么要@synthesize myProp = _myProp?还有为什么要 self 调用它。在前?

ios - 从viewcontroller调用方法到类xcode

iphone - 如何在iPhone SDK中实现UIProgressView

ios Google SignIn 集成不会从应用程序注销

ios - 使用 PhoneGap(构建与 xCode)我的 iOS 应用程序可以有多大?

xcode - "Products contains invalid products"Nativescript Xcode 存档

iphone - 使用 FMDB 执行 sqlite 查询时遇到问题

ios - 当我尝试创建从 UIWebview 到头文件的导出时,Xcode 崩溃

ios - Xcode 6.4 中弃用的 segues