Movable Button With Custom Image and Clicking
First download this project file and add to your project.
Now, implement this code in your viewController to use create movable button.
Import this:
#import "PicsLikeControl.h"
Set Delegate:
<PicsLikeControlDelegate>
Create global le object to:
PicsLikeControl *picControl; PicsLikeControl *picControl2;
Now, you can implement your viewDidLoad method:
- (void)viewDidLoad {
[super viewDidLoad];
// this is two image to set a button...
UIImage *image0=[UIImage imageNamed:@"image0"];
UIImage *image1 = [UIImage imageNamed:@"image1"];
UIImage *image0=[UIImage imageNamed:@"image0"];
UIImage *image1 = [UIImage imageNamed:@"image1"];
// first button...
picControl = [[PicsLikeControl alloc] initWithFrame:CGRectMake([strLX floatValue], [strLY floatValue], 60, 60) multiImages:images];
picControl.tag=0;
picControl.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
picControl.delegate = self;
[self.view addSubview:picControl];
// second button...
NSArray *images2 = @[image1];
picControl2 = [[PicsLikeControl alloc] initWithFrame:CGRectMake([strRX floatValue], [strRY floatValue], 60, 60) multiImages:images2];
picControl2.tag=1;
picControl2.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
picControl2.delegate = self;
[self.view addSubview:picControl2];
}
Now, create a Delegate method to handle click action on your button.
{
if (index == 0) {
// this is your first button click action to implement your action
} else {
// this is your second button click action to implement your action
}
}
Comments
Post a Comment
Thank You.