Search code examples
iphoneiosobjective-cios5uibutton

Not able to change the text size in a label when clicking a button


In my iphone app. I want to change the text size in a label when clicking a button


Solution

  • Create UILabel

    self.lbl=[[UILabel alloc] initWithFrame:CGRectMake(135, 290,200,35)];
        self.lbl.backgroundColor=[UIColor clearColor];
        NSString *str=[NSString stringWithFormat:@"%.f",[self.slider value]];
        [self.lbl setFont:[UIFont fontWithName:@"Arial-BoldMT" size:16]];
        self.lbl.text=str;
        [self.View addSubview:self.lbl];
    

    Change size of text of UILabel when tapped UIButton

    -(IBAction)ButtonPressed:(id)sender
    {
        [self.lbl setFont:[UIFont fontWithName:@"Arial-BoldMT" size:25]];
    }