ios 控件设置圆角和阴影

UIView *shadowView = [[UIView alloc] init];

//设置位置和大小

  shadowView.frame = CGRectMake(100,100,100,100);

//设置中心

    shadowView.center = self.view.center;

 //设置背景颜色

shadowView.backgroundColor = [UIColor whiteColor];

    //设置阴影颜色

shadowView.layer.shadowColor = [UIColor colorWithRed:114.0/255.0green:133.0/255.0blue:152.0/255.0alpha:1.0].CGColor;

    //设置阴影的透明度

shadowView.layer.shadowOpacity =0.1f;

    //设置阴影的偏移

shadowView.layer.shadowOffset = CGSizeMake(30.0f,10.0f);

    //设置阴影半径

shadowView.layer.shadowRadius =15.0f;

    //超出父视图部分是否显示 此处一定设置成NO 否则阴影不显示

shadowView.layer.masksToBounds = NO;

//设置圆角

 shadowView.layer.cornerRadius =3.0;

你可能感兴趣的:(ios 控件设置圆角和阴影)