UIView with rounded corners and drop shadow?

前端 未结 30 2642
一整个雨季
一整个雨季 2020-11-22 08:00

I’ve been working on an application for a couple of years and received a simple design request: Round the corners on a UIView and add a drop shadow.To do as given below.

30条回答
  •  遇见更好的自我
    2020-11-22 08:32

    Shadow + Border + Corner Radius enter image description here

        scrollview.backgroundColor = [UIColor whiteColor]; 
        CALayer *ScrlViewLayer = [scrollview layer];
        [ScrlViewLayer setMasksToBounds:NO ];
        [ScrlViewLayer setShadowColor:[[UIColor lightGrayColor] CGColor]];
        [ScrlViewLayer setShadowOpacity:1.0 ];
        [ScrlViewLayer setShadowRadius:6.0 ];
        [ScrlViewLayer setShadowOffset:CGSizeMake( 0 , 0 )];
        [ScrlViewLayer setShouldRasterize:YES];
        [ScrlViewLayer setCornerRadius:5.0];
        [ScrlViewLayer setBorderColor:[UIColor lightGrayColor].CGColor];
        [ScrlViewLayer setBorderWidth:1.0];
        [ScrlViewLayer setShadowPath:[UIBezierPath bezierPathWithRect:scrollview.bounds].CGPath];
    

提交回复
热议问题