我正在通过其图层构建自己的自定义按钮,如下所示:
[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];
结果是这样的:
看起来字体比它应该的高,但如果你仔细观察,实际上是按钮的框架被绘制得太低:字体和阴影是它们应该在的位置。
有谁知道我该如何解决这个问题?