zambono
zambono

Reputation: 1397

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;

Upvotes: 8

Views: 5598

Answers (2)

Christopher A
Christopher A

Reputation: 2961

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.

Upvotes: 27

hotpaw2
hotpaw2

Reputation: 70673

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.

Upvotes: 1

Related Questions