Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove a shadow in iPhone

I am using the standard way of making shadows from a button programmatically, but I would like to shadow to no longer exist after I am done with the button. I could set opacity to 0, but would the shadow still exist and if so would it still tax the system. thanks

this gives an error

tempButton.superview.layer.shadowOffset = nil;
    tempButton.superview.layer.shadowRadius = nil;
    tempButton.superview.layer.shadowOpacity = nil;
like image 230
zambono Avatar asked Aug 24 '11 21:08

zambono


2 Answers

I usually do the following to be safe.

  [[tempButton layer] setShadowOpacity:0.0];
  [[tempButton layer] setShadowRadius:0.0];
  [[tempButton layer] setShadowColor:nil];

Quartz is highly optimized and will not waste any time rendering if it doesn't have to.

like image 195
Christopher A Avatar answered Sep 22 '22 14:09

Christopher A


I would just remove the button, and replace it with an identical (but non-shadowed) button. Or keep both around and hide/unhide one of them. Sometimes it's easier to create a new UI object than munge around with an existing one.

like image 38
hotpaw2 Avatar answered Sep 19 '22 14:09

hotpaw2