2012-01-05 38 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;