Wednesday 8 June 2011

How to Create Image,Label,Button,Textfield,ScrollView.

UIImageView *LogoImage=[[UIImageView alloc]initWithFrame:CGRectMake(100.0,0.0 ,100.0, 60.0)];
[LogoImage setImage:[UIImage imageNamed:@"Logo.png"]];
[self.view addSubview:LogoImage];
[LogoImage release];

UILabel *addressLabel=[[UILabel alloc]initWithFrame:CGRectMake(10.0,123.0, 115.0, 100)] ;
addressLabel.text=@"iPhone";
[addressLabel setBackgroundColor:[UIColor clearColor]];
addressLabel.font=[UIFont fontWithName:@"Helvetica-Bold" size:16];
addressLabel.textAlignment= UITextAlignmentCenter;
addressLabel.textColor=[UIColor purpleColor];
[self.view addSubview:addressLabel];
[addressLabel release];

UIButton *GetDirectionButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
GetDirectionButton.frame=CGRectMake(30.0, 380.0, 100.0, 25.0);
[GetDirectionButton setBackgroundColor:[UIColor redColor]];
[GetDirectionButton setTitle:@"Go Apple" forState:UIControlStateNormal];
[GetDirectionButton setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
GetDirectionButton.font=[UIFont fontWithName:@"Helvetica-Bold" size:14];
[GetDirectionButton addTarget:self action:@selector(GetDirectionButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:GetDirectionButton];

UITextField *txtZipCode = [[UITextField alloc]initWithFrame:CGRectMake(28, 230, 265, 40)];
txtZipCode.borderStyle = UITextBorderStyleBezel;
txtZipCode.textColor = [UIColor blackColor];
txtZipCode.font = [UIFont systemFontOfSize:17];
txtZipCode.placeholder = @"Enter Zip Code";
txtZipCode.backgroundColor = [UIColor whiteColor];
txtZipCode.autocorrectionType = UITextAutocorrectionTypeNo;
txtZipCode.textAlignment = UITextAlignmentCenter;
txtZipCode.keyboardType = UIKeyboardTypeDefault;
txtZipCode.returnKeyType = UIReturnKeyDefault;
txtZipCode.clearButtonMode = UITextFieldViewModeWhileEditing;
txtZipCode.delegate = self;
txtZipCode.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[scrollview addSubview:txtZipCode];
[txtZipCode release];

UIScrollView *scrollview =[[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320, 480)];
scrollview.contentSize=CGSizeMake(320,563);
[scrollview setBackgroundColor:[UIColor blackColor]];
scrollview.clipsToBounds=YES;
scrollview.contentOffset=CGPointMake(0.0,0.0);
scrollview.contentInset=UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);
scrollview.scrollEnabled=YES;
[self.view addSubview:scrollview];

No comments:

Post a Comment