Pier
Pier

Reputation: 10817

Ios app icon class

Is there a UI class that corresponds to the app icons on the home screen?

Or some kind of button that is similar and also has a method for the wobble effect?

Upvotes: 0

Views: 381

Answers (1)

Andrew
Andrew

Reputation: 2710

Short answer, no.

It's up to the developer to recreate these effects using the SDK. It's simple enough to make a custom UIButton with an image (app icon). Then it's just a matter of adding in the appropriate long press gesture handling to activate the editable status of the button and start it wiggling.

-(void)viewDidLoad {
  // make a UIButton
  UIButton *myWiggleButton = [UIButton buttonWithType:UIButtonTypeCustom];
  // set an image for the button
  [myWiggleButton setImage:[UIImage imageNamed:@"my_app_image.png"] forState:UIControlStateNormal];
      // add an action and target for the button
  [myWiggleButton addTarget:self action:@selector(myButtonTapped:)   forControlEvents:UIControlEventTouchUpInside];
      // finally add a long touch gesture recognizer
  UILongPressGestureRecognizer *longPressGesture =
                [[[UILongPressGestureRecognizer alloc]
                  initWithTarget:self action:@selector(startWiggleMode:)] autorelease];
  [myWiggleButton addGestureRecognizer:longPressGesture];
}

-(void)startWiggleMode:(UIGestureRecognizer*)recognizer
{
  // start a wiggling animation for the button.
  // add a UIButton for the 'x' on top of the wiggling button
}

-(void)myButtonTapped:(id)sender
{
  // handle button tap case here.
}

Upvotes: 3

Related Questions