为什么在以编程方式创建时UIButton模糊不清

时间:2015-10-12 09:13:55

标签: ios objective-c uibutton

我创建了一个像这样的uibutton:

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(280, 320, 100, 30);
[button setTitle:@"World" forState:UIControlStateNormal];
[button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
button.backgroundColor= [UIColor clearColor];
[cell.contentView addSubview:button];

按钮的文字看起来很锋惠,有人知道为什么吗?

2 个答案:

答案 0 :(得分:0)

更改

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
                                                        ^^^^^^

一切都会好..

答案 1 :(得分:0)

尝试给予Font:

 // Configure the cell...
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(0, 0, 100, 30);
    [button setTitle:@"World" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    button.titleLabel.font=[UIFont fontWithName:@"HelveticaNeu-CondensedBold" size:16];
    button.backgroundColor= [UIColor clearColor];
    [cell.contentView addSubview:button];