设置部分圆角
dispatch_async(dispatch_get_main_queue(), ^{
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:cell.tipBgImgView.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(18*hzoom, 18*hzoom)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = cell.tipBgImgView.bounds;
maskLayer.path = maskPath.CGPath;
cell.tipBgImgView.layer.mask = maskLayer;
});
阴影效果
UIView *shadowView = [[UIView alloc]initWithFrame:CGRectMake(40*wzoom, 88*hzoom, ScreenWidths-80*wzoom, 254*hzoom)];
[_headBgView addSubview:shadowView];
shadowView.layer.shadowColor = Gray201.CGColor;
shadowView.layer.shadowOffset = CGSizeMake(0, 0);
shadowView.layer.shadowOpacity = 0.8;
shadowView.layer.shadowRadius = 14.0;
shadowView.layer.cornerRadius = 14.0;
_scrolWhiteBgView = [[UIView alloc] initWithFrame:shadowView.bounds];
_scrolWhiteBgView.layer.masksToBounds = YES;
_scrolWhiteBgView.layer.cornerRadius = 14;
_scrolWhiteBgView.backgroundColor = White;
[shadowView addSubview:_scrolWhiteBgView];
1.圆角
[view.layer setCornerRadius:3];
view.layer.masksToBounds = YES;
2.边框
view.layer.borderWidth = 1.0;
view.layer.borderColor = [[UIColor redColor] CGColor];
3.移除子控件
for(UIView *view in [view subviews])
{
[view removeFromSuperview];
}
4.自定义菊花
1.新建一个类MyActivityIndicatorView,继承于UIActivityIndicatorView,添加初始化方法
先定义宏(模拟器为iPhone6)
#define kWidth 375
#define KHeight 667
#define MYCOLOR [UIColor blackColor]
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// 菊花背景的大小
self.frame = CGRectMake(kWidth/2-50, KHeight/2-50, 100, 100);
// 菊花的背景色
self.backgroundColor = MYCOLOR;
self.layer.cornerRadius = 10;
// 菊花的颜色和格式(白色、白色大、灰色)
self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
// 在菊花下面添加文字
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 60, 80, 40)];
label.text = @"loading...";
label.font = [UIFont systemFontOfSize:14];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor whiteColor];
[self addSubview:label];
}
return self;
}
2.在加载网络之前调用该方法
// 自带菊花方法
self.myActivityIndicatorView = [[MyActivityIndicatorView alloc]init];
[self.view addSubview:_myActivityIndicatorView];
// 动画开始
[_myActivityIndicatorView startAnimating];
3.网络请求完成,数据加载后调用取消动画方法
// 动画结束
[_myActivityIndicatorView stopAnimating];
5.禁止屏幕旋转
- (BOOL)shouldAutorotate {
return NO;
}