我在控制器上放了一个自定义视图,自定义视图的高度非常高。然后当我滚动非常慢的控制器时
测试环境:IOS5.0+,ipod touch
自定义视图:
@interface UICommonView : UIView
//.....
@end
@implementation UICommonView
//.....
-(void)setBorder:(CGFloat)width color:(UIColor*)color
{
self.frameColor = color;
self.frameWidth = width;
[self.layer setBorderWidth:width];
[self.layer setBorderColor:[color CGColor]];
}
-(void)makeShadow
{
self.layer.shadowOpacity = 0.7f;
self.layer.shadowOffset = CGSizeMake(5.0f,3.0f);
self.layer.shadowColor =[[UIColor blackColor] CGColor];
}
-(void)makeCornerRadius:(CGFloat)_cornerRadius
{
self.cornerRadius = _cornerRadius;
[self.layer setMasksToBounds:NO];
[self.layer setCornerRadius:_cornerRadius];
}
@end
控制器:
//contentView is UICommonView
//scrollView is UIScrollView on controller
-(void)viewDidLoad
{
[self.contentView makeShadow];
[self.contentView makeCornerRadius:5.0f];
[self.contentView setBorder:4.0f color:[UIColor white]];
// self.contentView.backgroundColor = //......
[self.contentView setFrame:CGRectMake(0,0,320,1200)];
[self.scrollView addSubview:contentView];
scrollerView.contentSize = CGSizeMake(320,1300);
//add other view
//I tested, only custom View impact speed
}
如何优化它。谢谢!!