iOS開發 view新增陰影
阿新 • • 發佈:2018-11-21
建立控制元件
UIView * view = [[UIView alloc] initWithFrame:CGRectMake(WIDTH/2-85, self.frame.size.height-15, 170, 30)];
view.hidden = YES;
view.backgroundColor = [UIColor whiteColor];
view.clipsToBounds = YES;
view.layer.cornerRadius = 5;
[self addSubview:view];
新增陰影
UIBezierPath *shadowPath = [UIBezierPath
bezierPathWithRect:view.bounds];
view.layer.masksToBounds = NO;
view.layer.shadowColor = [UIColor lightGrayColor].CGColor;
view.layer.shadowOffset = CGSizeMake(0.0f, 1.0f);
view.layer.shadowOpacity = 0.5f;
view.layer.shadowPath = shadowPath.CGPath;