gpt4 book ai didi

ios - UIButton字体不流畅

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:54:06 24 4
gpt4 key购买 nike

我在 View 中添加了一些 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++;
}
}
}

最佳答案

解决的问题:

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;

关于ios - UIButton字体不流畅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8740047/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com