Tuesday 17 December 2013

Change background color

delegate.h
------------------

#import <UIKit/UIKit.h>

@interface second : UIViewController
{
    IBOutlet UIButton *B1;
    IBOutlet UIButton *B2;
    IBOutlet UIButton *B3;
}

-(IBAction)First:(id)sender;
-(IBAction)Second:(id)sender;
-(IBAction)Third:(id)sender;

@end

Viewcontroller.h
----------------------
#import "second.h"

@implementation second

-(IBAction)First:(id)sender
{
    self.view.backgroundColor = [UIColor redColor];
}

-(IBAction)Second:(id)sender
{
    self.view.backgroundColor = [UIColor greenColor];
}

-(IBAction)Third:(id)sender
{
    self.view.backgroundColor = [UIColor yellowColor];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

No comments:

Post a Comment

Comment