1

I have an irregular shaped custom button and I would like for it to animate with the curl up effect. The problem is that Xcode places my irregular shaped button in a rectangle. The button is a .png and the transparency is preserved. On the simulator when the button curls up, the whole rectangular area marked by a black background curls up with it. I was wondering how it would be possible to just have the button curve up. Is it even possible to do that? Thanks!

DanielRak
  • 239
  • 1
  • 2
  • 11
  • What code are you using to animate the button? Are you animating the layer or are you animating the view? Can you post an example? – MobileOverlord Feb 07 '12 at 01:35
  • @MobileOverlord I'm using this code to animate the view. I have the UIButton connected through IB with the touch up inside event. - (IBAction)btnClick:(id)sender{ [UIButton beginAnimations:nil context:nil]; [UIButton setAnimationDuration:2.0]; [UIButton setAnimationBeginsFromCurrentState:YES]; [UIButton setAnimationTransition:UIViewAnimationTransitionCurlUp forView:(UIView*)sender cache:YES]; ((UIView*)sender).hidden = YES; [UIButton commitAnimations]; } – DanielRak Feb 07 '12 at 04:08
  • Sorry for the format. I'm trying to figure out how to put in the code tags over here... – DanielRak Feb 07 '12 at 04:16
  • @MobileOverlord I believe the problem is that Xcode automatically puts my UIImage in a UIButton that's bound by a rectangle. So in the XIB the bounds of my UIButton are in a rectangle around the actual irregular shape of my UIImage. Thus, when I use the curl up animation, it curls up the whole rectangular frame instead of just the UIImage. – DanielRak Feb 07 '12 at 04:47

2 Answers2

1

Unfortunately is not possible. It's an UIViewAnimation, as it says is applied to the whole UIView frame. You can make the background transparent but the shadows will be projected from the containing frame's bounds, resulting in a very ugly effect. I'm looking for some bespoke code which can replicate the effect, but so far I have found nothing interesting.

Andrea
  • 638
  • 9
  • 20
0

you could make it a UIImageView with the image loaded and animate this instead of making a UIButton. But then you have to write the code to react to touch events on your own...

Gotschi
  • 3,175
  • 2
  • 24
  • 22