Saturday, September 15, 2012

Dynamic IBOoutlet creation

UIbutton Creation
CGRect frame = CGRectMake(10, 10, 100, 30);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = frame;
[button setTitle:(NSString *)@"new button" forState:(UIControlState)UIControlStateNormal];
[button addTarget:self action:@selector(yourButtonClickMethod:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

UILabel Creation

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 70)];
label.numberOfLines = 2;
label.text = @"text";
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];

label.highlightedTextColor = [UIColor blackColor];
label.textAlignment = UITextAlignmentLeft;
label.font = [UIFont systemFontOfSize:12];
[self.view addSubview:label];



No comments:

Post a Comment