【问题标题】:Not able to change the text size in a label when clicking a button单击按钮时无法更改标签中的文本大小
【发布时间】:2013-01-03 00:12:48
【问题描述】:

在我的 iPhone 应用程序中。我想在单击按钮时更改标签中的文本大小

【问题讨论】:

    标签: iphone ios objective-c ios5 uibutton


    【解决方案1】:

    创建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];
    

    点击UIButton时更改UILabel的文本大小

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

    【讨论】:

      【解决方案2】:
      -(IBAction)changeFontOfLabel:(id)sender
      {
         [self.lebelObject setFont:[UIFont fontWithName:@"American Typewriter" size:18];
      }
      

      并写下正确的字体名称。在这里查看fonts的列表

      【讨论】:

        【解决方案3】:

        这里是如何在运行时更改字体大小....

        yourLabel.font=[UIFont systemFontOfSize:14];
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-05-04
          • 1970-01-01
          • 2015-06-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-11-16
          相关资源
          最近更新 更多