UIScrollview内に表示するカスタムUIViewを実装しています。問題は、シャドウをドロップするためのビューが必要なことです。
#import <QuartzCore/QuartzCore.h>
@implementation CustomView
-(void)setupView{
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowOpacity = 0.5;
self.layer.shadowRadius = 1;
self.layer.shadowOffset = CGSizeMake(.6f, .6f);
self.layer.cornerRadius = 2;
[...]
}
-(id)initWithFrame:(CGRect)frame{
if((self = [super initWithFrame:frame])){
[self setupView];
}
return self;
}
[...]
重要なのは、これをビルドして実行すると、スクロールビューが非常に遅くなり、「self.layer」をハッキングしていた行を削除するだけで、スクロールビューが再び高速でスムーズになります。
カスタムビューにシャドウを追加する適切な方法は何ですか?