gpt4 book ai didi

iphone - 居中 UIPickerView 文本

转载 作者:行者123 更新时间:2023-12-03 18:13:34 29 4
gpt4 key购买 nike

所以我有一个 uipickerview,其中的行仅包含数字 0-24,它看起来有点傻,因为数字左对齐,在 pickerview 的右侧留下了巨大的间隙。

是否有一种简单的方法可以在 uipickerview 中居中对齐文本?

最佳答案

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)];
label.text = [NSString stringWithFormat:@"something here"];
label.textAlignment = NSTextAlignmentCenter; //Changed to NS as UI is deprecated.
label.backgroundColor = [UIColor clearColor];
[label autorelease];
return label;
}

或者类似的东西。

关于iphone - 居中 UIPickerView 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5038891/

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