---
title: "Displaying shadow under bottom edge of UIView Controller in iOS."  
description: "Displaying shadow under bottom edge of UIView Controller in iOS."  
author: "Anonymous User"  
published: 2016-01-02  
updated: 2016-01-03  
canonical: https://www.mindstick.com/forum/33824/displaying-shadow-under-bottom-edge-of-uiview-controller-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Displaying shadow under bottom edge of UIView Controller in iOS.

I want to display a [shadow](https://yourviews.mindstick.com/view/87467/muslims-are-destroying-hindu-villages-under-the-shadow-of-mamta-banerjee) on UIView [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) because I have a need in our [iPhone application](https://www.mindstick.com/forum/23139/can-i-embed-a-custom-font-in-an-iphone-application) to display a shadow under the bottom [edge](https://yourviews.mindstick.com/view/85544/beyond-locks-and-passcodes-the-cutting-edge-of-mobile-data-security) of **UIView** Controller.\
I have searched and found **CGContextSetShadow()** for drawing the shadow, but still I have getting [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic):\
Here is my code:

```
-(void)drawRect:(CGRect)rect {  CGContextRef context = UIGraphicsGetCurrentContext();  CGContextSaveGState(context);  CGContextSetShadow(context, CGSizeMake(-25,15),8);  CGContextRestoreGState(context);  [super drawRect: rect];}
```

but the above code is not working.\
[Please tell me](https://www.mindstick.com/forum/33900/please-tell-me-what-are-the-technique-to-content-optimization) what is [wrong](https://answers.mindstick.com/qa/48468/who-wrote-the-the-wrong-enemy-america-in-afghanistan-2001-2014-and-when) in my code if any. or is any other best solution for that then please provide [me the code](https://www.mindstick.com/forum/156831/can-you-tell-me-the-code-to-write-a-c-sharp-program).\
Thank you.

## Replies

### Reply by Tarun Kumar

Any type of shadow will be affected after the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
CGContextSetShadow(context,CGSizeMake(-25, 15), 8);
```

but use above code before this code:

```
CGContextRestoreGState(context);
```

here is your complete code:

```
-(void)drawRect:(CGRect)rect {  CGContextRef context=UIGraphicsGetCurrentContext();  CGContextSaveGState(context);  CGContextSetShadow(context,CGSizeMake(-25,15),8);  [super drawRect:rect];  CGContextRestoreGState(context);}
```


---

Original Source: https://www.mindstick.com/forum/33824/displaying-shadow-under-bottom-edge-of-uiview-controller-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
