我正在构建我自己的自定义按钮,如下所示:
[self.layer setBorderColor:[UIColor colorWithWhite:.94 alpha:1].CGColor];
[self.layer setBorderWidth:1];
[self setBackgroundColor:[UIColor colorWithWhite:.86 alpha:1]];
[self.titleLabel setFont:[UIFont fontWithName:@"AdelleBasic-Bold" size:18]];
[self setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[self.layer setShadowRadius:4];
[self.layer setShadowOpacity:.4];
[self.layer setShadowColor:[UIColor colorWithWhite:.5 alpha:1].CGColor];
[self.layer setCornerRadius:5];
结果如下:
看起来字体高于应有的字体,但如果仔细观察,实际上按钮的框架绘制得太低了:字体和阴影是他们想要的位置。
任何人都知道如何解决这个问题?