我使用的特定字体遇到了一些麻烦.它是为学校制作的,因此A和Å的高度不同.我认为这会给我的UIButton带来麻烦.我试图解决它,但似乎无法做到正确.这是我上次尝试过的:
[self setValue:[UIFont fontWithName:@"fontname" size:220] forKeyPath:@"button1.font"]; [self setValue:[UIFont fontWithName:@"fontname" size:220] forKeyPath:@"button2.font"]; [self setValue:[UIFont fontWithName:@"fontname" size:220] forKeyPath:@"button3.font"]; [button1 setTitle:@"A" forState:UIControlStateNormal]; [button2 setTitle:@"Å" forState:UIControlStateNormal]; [button3 setTitle:@"Å" forState:UIControlStateNormal]; [button2 setBackgroundColor:[UIColor blackColor]]; [button2 setFrame:CGRectMake(button2.frame.origin.x, button2.frame.origin.y, button2.frame.size.width, button2.frame.size.height+100)]; [button2.titleLabel setFrame:CGRectMake(button2.frame.origin.x, button2.frame.origin.y, button2.frame.size.width, button2.frame.size.height)]; button2.cOntentVerticalAlignment= UIControlContentVerticalAlignmentBottom;
这是结果:
如您所见,Å未正确显示.我怎样才能解决这个问题?
谢谢!
最好的问候,Joakim
我用以下方法解决了这个问题.
假设你的xib或storyboard中有一个UIButton
选择UIButton
转到属性检查器
查找控件类别
查找对齐方式
选择Vertical属性的最右侧按钮!