次のように、レイヤーを介して独自のカスタムボタンを作成しています。
[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];
結果は次のとおりです。
フォントが本来よりも高いように見えますが、よく見ると、実際にはボタンのフレームが低すぎます。フォントとドロップ シャドウは本来あるべき位置にあります。
これを修正する方法を知っている人はいますか?