2012-01-05 32 views
2

我添加一些UIButton的到视图,但在按键的字体似乎(在视网膜屏)不流畅....UIButton的字体不光滑

看到图像:enter image description here

谁能帮助?谢谢!

这里是我添加按钮方法:

- (void)setItems:(NSArray *)items { 
    if (_items != items) { 
     _items = items; 
     for (UIView *v in self.containerView.subviews) { 
      [v removeFromSuperview]; 
     } 
     int i = 1; 
     CGFloat y = 8; 
     for (id item in _items) { 
      UIButton *itemButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
      itemButton.frame = CGRectMake(0, y, self.containerView.bounds.size.width, 35); 
      itemButton.tag = i; 
      [itemButton setTitle:item forState:UIControlStateNormal]; 
      [itemButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
      [itemButton setBackgroundImage:[UIImage imageNamed:@"bg.png"] forState:UIControlStateHighlighted]; 
      itemButton.titleLabel.font = [UIFont boldSystemFontOfSize:20]; 
      [itemButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; 
      y += 35; 
      [self.containerView addSubview:itemButton]; 
      i++; 
     } 
    } 
} 
+0

你是如何创建按钮并添加/绘制文本? – jrturton 2012-01-05 09:20:40

+0

@jrturton我上面发布了它。 – 2012-01-05 09:24:18

+0

屏幕截图显示一个按钮?我不清楚循环或按钮的大小。 – jrturton 2012-01-05 09:33:30

回答

1

问题解决:

self.containerView = [[UIScrollView alloc] initWithFrame:frame]; 
UIScreen *mainScreen = [UIScreen mainScreen]; 
if ([mainScreen respondsToSelector:@selector(scale)]) { 
    self.containerView.contentScaleFactor = mainScreen.scale; 
} 

self.containerView.contentScaleFactor = mainScreen.scale;