I've literally tried everything I could but none of them work for a custom UIView
... I just wanted a blank white view with rounded corners and a light drop shadow (with no lighting effect). I can do each of those one by one but the usual clipToBounds
/maskToBounds
conflicts occur.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
Swift 4 : Create Subclass of UIView
Using..
The answer provided by Evan Mulawski will work perfectly. The catch is that you have to set the background color for the view to clearColor and the masksToBounds property to NO.
You can set whatever color you want for the view, set it like
Hope this helps..
I solved the problem using the following trick when assigning shadow path for the container view :
Notice that the path given to the shadow is a rounded rectangle with the same corner radius as the background that the cell contains:
daniel.gindi's answer above did the trick for me! (+1 daniel) However, I had to make minor adjustments - change the shadowFrame size to be same as view's frame size, and enable user interaction. Here's the updated code:
I would like to add that in my case, I was trying to add this to a 3rd party view controller, i.e. I did not have direct control over the code. So, here's how I used the function above:
One way to do this is to put the view with rounded corners in a view with the drop shadow.
Then you can add the shadowView wherever you want.
You need to use two
UIViews
to achieve this. OneUIView
will work like shadow and other one will work for rounded border.Here is a code snippet a
Class Method
with a help of aprotocol
:In the code above
btnCompose_click:
will become a@required
delegate method which will fire on the button click.And here I added a button to my
UIViewController
like this:The result will look like this: