-(void) loadView
{
UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
view.backgroundColor =[UIColor lightGrayColor];
CGRect frame =CGRectMake(10, 15, 300, 20);
UILabel *label = [[UILabel alloc] initWithFrame:frame];
label.textAlignment =UITextAlignmentLeft;
label.backgroundColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@"Verdana" size:20];
label.text = @"This is Label";
label.tag = 1000;
frame =CGRectMake(10, 50, 300, 50);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = frame;
[button setTitle:@"This is a button" forState:UIControlStateNormal];
button.backgroundColor = [UIColor clearColor];
button.tag = 2000;
[button addTarget:self
action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];
[view addSubview:label];
[view addSubview:button];
self.view = view;
[label release];
}
-(IBAction) buttonClicked:(id) sender{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Button Clicked"
message:@"Hello"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
2011年6月24日金曜日
Page Animation
NSInteger nextPage = [pageControl currentPage];
[tempImageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"pic%d.jpg",nextPage+1]]];
if (tempImageView.tag == 0) {
tempImageView = imageView2;
bgImageView = imageView1;
}
else{
tempImageView = imageView1;
tempImageView = imageView2;
}
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:tempImageView
cache:YES];
[tempImageView setHidden:YES];
[UIView commitAnimations];
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:bgImageView
cache:YES];
[tempImageView setHidden:NO];
[UIView commitAnimations];
[tempImageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"pic%d.jpg",nextPage+1]]];
if (tempImageView.tag == 0) {
tempImageView = imageView2;
bgImageView = imageView1;
}
else{
tempImageView = imageView1;
tempImageView = imageView2;
}
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:tempImageView
cache:YES];
[tempImageView setHidden:YES];
[UIView commitAnimations];
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:bgImageView
cache:YES];
[tempImageView setHidden:NO];
[UIView commitAnimations];
登録:
コメント (Atom)