有没有人在UILabel中使用digital-7字体,我发现文本要在底部对齐(在Y轴上对齐太低,而不是在标签的垂直中心)。有没有人有办法让他们居中对齐?
发布于 2012-01-13 14:42:33
你要问的是,对于这种特殊的字体,它在Y轴上对齐太低,而不是在标签的垂直中心。一些解决方案:
setFrame调用来完成此操作。据我所知,UIFont根本没有携带这些信息。不过,它可能是:you can check some of the read-only properties of the font。
尽管如此,你仍然不能在字体上设置属性,所以你不能以这种方式调整它。
发布于 2012-01-13 14:19:57
试试这个..。
UILabel *testLabel = [[UILabel alloc] initWithFrame:CGRectMake(148, 142, 130, 25)];
[testLabel setFont:[UIFont fontWithName:@"DBLCDTempBlack" size:20]];
[testLabel setText:@"MY Text"];
[testLabel setTextColor:[UIColor darkGrayColor]];
[testLabel setBackgroundColor:[UIColor clearColor]];
[testLabel setTextAlignment:UITextAlignmentCenter];发布于 2012-01-13 14:49:12
我之前在我的项目中使用过自定义字体。您只需在项目中添加font.tff文件并使用setFont方法设置字体
https://stackoverflow.com/questions/8846607
复制相似问题