Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have edited this in light of the suggestion from moonlight. I put that code into a method addInnerTopShadow when a cell needs that I call the method. I have added another method addInnerBottomShadow which puts in the shadow at the bottom.</p> <p>I call these methods in the drawRect method and when I want to change between the states I call the method:</p> <pre><code>[cell setNeedsDisplay]; </code></pre> <p>This allows me to toggle the state of the cell without doing things like</p> <pre><code>[self.tableView reloadData]; </code></pre> <p>As the methods suggest I have outer shadow methods that put a shadow on the first and last cells but that's another issue and has been answered many times. I now have my app working exactly how I want. So thanks to Rob and Moonlight.</p> <pre><code>-(void)addInnerBottomShadow { CGContextRef context = UIGraphicsGetCurrentContext(); // Creating path which will hold our hollow rectangle CGMutablePathRef path = CGPathCreateMutable(); CGPathAddRect(path, NULL, CGRectMake(0, 44, 480, 80)); CGPathAddRect(path, NULL, CGRectMake(0, 54, 480, 96)); // Saving current graphics context state CGContextSaveGState(context); // Configuring shadow CGContextSetShadowWithColor(context, CGSizeMake(0.0f, 0.0f), 6.0f, [[UIColor blackColor] CGColor]); // Adding our path CGContextAddPath(context, path); // Configure hollow rectangle fill color CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); // Fill rectangle and keep hollow part transparent CGContextEOFillPath(context); CGContextClipToRect(context, self.bounds); // Restore graphics context CGContextRestoreGState(context); } -(void)addInnerTopShadow { CGContextRef context = UIGraphicsGetCurrentContext(); CGMutablePathRef path = CGPathCreateMutable(); CGPathAddRect(path, NULL, CGRectMake(-8.0f, -8.0f, 336.0f, 96.0f)); CGPathAddRect(path, NULL, CGRectMake(-5.0f, 0.0f, 330.0f, 80.0f)); // Saving current graphics context state CGContextSaveGState(context); // Configuring shadow CGContextSetShadowWithColor(context, CGSizeMake(0.0f, 0.0f), 7.0f, [[UIColor blackColor] CGColor]); // Adding our path CGContextAddPath(context, path); // Configure hollow rectangle fill color CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); // Fill rectangle and keep hollow part transparent CGContextEOFillPath(context); CGContextClipToRect(context, self.bounds); // Restore graphics context CGContextRestoreGState(context); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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