UIButton шрифт не гладкий - PullRequest
       1

UIButton шрифт не гладкий

2 голосов
/ 05 января 2012

Я добавляю немного 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++;
        }
    }
}

1 Ответ

1 голос
/ 06 января 2012

Проблема решена:

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;

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...