我有以下代码:
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)大小也根本没有变化。我尝试增加字体大小,它没有改变,我尝试减小字体大小,它也没有改变。
我究竟做错了什么?