UITableviewcell custom button is fly like rocket animation.
#pragma mark - Table View - Favorite Click
-(IBAction)cell_fav_clicked:(id)sender
UIButton *btn_select = (UIButton *)sender;
NSInteger row_id= btn_select.tag;
NSIndexPath *ip = [NSIndexPath indexPathForRow:row_id inSection:0];
[self Favorite_Animation:ip button:btn_select];
}
-(void)Favorite_Animation:(NSIndexPath*)indexPath button:(UIButton *)btn
{
// get the exact location of button
CGRect rect = [btn.superview convertRect:btn.frame fromView:nil];
rect = CGRectMake(btn.frame.origin.x+50, (rect.origin.y*-1)-10, btn.frame.size.width, btn.frame.size.height);
NSLog(@"rect is %f,%f,%f,%f",rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
// create new duplicate button
btn= [[UIButton alloc]init];
[btn setFrame:rect];
[btn setImage:img_fav_highlight forState:UIControlStateNormal];
[self.view addSubview:btn];
[UIView animateWithDuration:1.0 animations:^(void) {
[btn setFrame:CGRectMake(300,-225, 42, 42)];
}];
}
Comments
Post a Comment