【问题标题】:UIButton title clippedUIButton 标题被剪裁
【发布时间】:2014-09-07 18:36:46
【问题描述】:

我有一个带有字体的自定义按钮。

customButtonSynchronize = [UIButton buttonWithType:UIButtonTypeCustom];
customButtonSynchronize.frame=CGRectMake(578, 27.5, 91, 29) ;
[customButtonSynchronize setBackgroundImage:[UIImage imageNamed:@"synchronize.png"]
                                   forState:UIControlStateNormal];
customButtonSynchronize.titleLabel.font = [UIFont fontWithName:@"HelveticaLTStd-Roman" size:14.0f];
[customButtonSynchronize setTitle:@"Sincronizzare" forState:UIControlStateNormal];
/////HERE//////////
customButtonSynchronize.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
customButtonSynchronize.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
customButtonSynchronize.contentEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
customButtonSynchronize.backgroundColor=[UIColor clearColor];
[customButtonSynchronize addTarget:self action:@selector(synchronizeDB:) forControlEvents:UIControlEventTouchUpInside];

但是上面的文字好像有点“Cut off”了。见“S”的顶部。

我不想改变按钮的框架,字体的大小。改变插图不能避免这个问题。是模拟器错误还是 helvetica 字体的问题?有什么解决办法吗?

【问题讨论】:

标签: ios ipad ios7 uibutton


【解决方案1】:

将 uibutton 标题设置为 nil,然后使用文本创建标签并将子视图添加到 uibutton 就是这样,现在它将根据您的需要正确显示文本

【讨论】:

    猜你喜欢
    • 2012-04-29
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多