我有以下代码:
我正在尝试在视图中以编程方式添加按钮。 MyCustomRect的参数为(0,0,75,50)。
两件事: a)无论我输入什么字体,它始终显示系统字体。 b)大小也根本不改变。我尝试增加字体大小,它不会改变,我尝试减小字体大小,它也不会改变。
我做错了什么?
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"My Title" forState:UIControlStateNormal];
button.frame = myCustomRect;
UIColor *fontColor = [UIColor colorWithRed:0.43 green:0.84 blue:0.86 alpha:0.9];
[button setTitleColor:fontColor forState:UIControlStateNormal];
button.backgroundColor = [UIColor whiteColor];
button.titleLabel.textAlignment = NSTextAlignmentCenter;
button.titleLabel.font = [UIFont fontWithName:@"Cooperplate" size:9];
[button addTarget:self
action:@selector(moreDetails:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
我正在尝试在视图中以编程方式添加按钮。 MyCustomRect的参数为(0,0,75,50)。
两件事: a)无论我输入什么字体,它始终显示系统字体。 b)大小也根本不改变。我尝试增加字体大小,它不会改变,我尝试减小字体大小,它也不会改变。
我做错了什么?