Note that there are some explanatory texts on larger screens.

plurals
  1. PORounded UIView with Shadow?
    primarykey
    data
    text
    <p>So using this link: <a href="https://stackoverflow.com/questions/805872/how-do-i-draw-a-shadow-under-a-uiview">How do I draw a shadow under a UIView?</a></p> <p>And this link: <a href="http://iphonedevelopment.blogspot.com/2008/11/creating-transparent-uiviews-rounded.html" rel="nofollow noreferrer">http://iphonedevelopment.blogspot.com/2008/11/creating-transparent-uiviews-rounded.html</a></p> <p>I came upon this implementation:</p> <pre><code>- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextSetShadow(context, CGSizeMake(-15.0f, 20.0f), 5.0f); CGContextSetLineWidth(context, strokeWidth); CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor); CGContextSetFillColorWithColor(context, self.rectColor.CGColor); CGRect rrect = self.bounds; CGFloat radius = cornerRadius; CGFloat width = CGRectGetWidth(rrect); CGFloat height = CGRectGetHeight(rrect); // Make sure corner radius isn't larger than half the shorter side if (radius &gt; width/2.0) radius = width/2.0; if (radius &gt; height/2.0) radius = height/2.0; CGFloat minx = CGRectGetMinX(rrect); CGFloat midx = CGRectGetMidX(rrect); CGFloat maxx = CGRectGetMaxX(rrect); CGFloat miny = CGRectGetMinY(rrect); CGFloat midy = CGRectGetMidY(rrect); CGFloat maxy = CGRectGetMaxY(rrect); CGContextMoveToPoint(context, minx, midy); CGContextAddArcToPoint(context, minx, miny, midx, miny, radius); CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius); CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius); CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius); CGContextClosePath(context); CGContextDrawPath(context, kCGPathFillStroke); CGContextRestoreGState(context); } </code></pre> <p>However when it draws, the shadow is clipped to the bounds of the view. I have tried setting self.clipsToBounds = NO however this doesn't affect the problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload