//View
CGFloat x=10;
CGFloat y=20;
img.alpha=0;
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 420)];
view.backgroundColor=[UIColor purpleColor];
[self.view addSubview:view];
/*scroll view*/
UIScrollView *sc=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 300, 400)];
sc.userInteractionEnabled=YES;
sc.backgroundColor=[UIColor greenColor];
sc.delegate=self;
sc.scrollEnabled=YES;
sc.contentSize=CGSizeMake(400,500);
[self.view addSubview:sc];
//textbox
for(int i=0;i<5;i++)
{
textfield=[[UITextField alloc]initWithFrame:CGRectMake(x, y, 100, 40)];
textfield.tag=i;
textfield.backgroundColor=[UIColor brownColor];
y+=50;
[sc addSubview:textfield];
[textfield addTarget:self action:@selector(textFieldShouldReturn:) forControlEvents:UIControlEventEditingDidEndOnExit];
}
//button
btn =[[UIButton alloc]initWithFrame:CGRectMake(150, 20, 100, 35) ];
[UIButton buttonWithType:UIButtonTypeCustom] ;
btn.backgroundColor=[UIColor greenColor];
[btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
[btn setTitle:@"click" forState:UIControlStateNormal];
[sc addSubview:btn];
//image
img=[[UIImageView alloc]initWithFrame:CGRectMake(120, 70, 150, 150) ];
[img setBackgroundColor:[UIColor grayColor]];
img.image=[UIImage imageNamed:@"sprathana.jpg"];
[sc addSubview:img];
//label
lb=[[UILabel alloc]initWithFrame:CGRectMake(150, 80, 80, 30)];
lb.text=@"welcome";
lb.backgroundColor=[UIColor lightGrayColor];
[sc addSubview:lb];
//slider
sli=[[UISlider alloc]initWithFrame:CGRectMake(150, 250, 70, 70)];
sli.maximumValue=1;
sli.minimumValue=0;
[sc addSubview:sli];
sli.userInteractionEnabled=YES;
img.alpha=sli.value;
img.alpha=1-sli.value;
[sli addTarget:self action:@selector(move:) forControlEvents:UIControlEventValueChanged];
[self.view endEditing:YES];
No comments:
Post a Comment