zoukankan      html  css  js  c++  java
  • UIButton 设置字体大小

    btn.frame = CGRectMake(x, y, width, height);

    [btn setTitle@"search" forStateUIControlStateNormal];

    //设置按钮上的自体的大小

    //[btn setFont: [UIFont systemFontSize: 14.0]];    //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法

    //应该使用

    btn.titleLabel.font = [UIFont systemFontOfSize14.0];

    [btn seBackgroundColor: [UIColor blueColor]];

    //最后将按钮加入到指定视图superView

    [superView addSubview: btn];

     

    附:创建按钮的两种方法:

    1、动态创建
    btnfont = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnfont setFrame:CGRectMake(100, 10, 120, 40)];
    [btnfont addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
    [btnfont setTitle:@"字体" forState:UIControlStateNormal];
    btnfont.backgroundColor=[UIColor clearColor];
    [self.view addSubview:btnfont];
    2、在xib文件中已经创建好,通过tag获取按钮
    UIButton *testButton= (UIButton*)[self.view viewWithTag:100];
    [testButton addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];

    注册事件
    -(void) test: (id) sender{

    UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"ceshi" message:@"test11111" delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil] autorelease];

    [av show];

    }

  • 相关阅读:
    Flask_脚本
    数据库
    模板
    视图函数和视图类
    HTTP请求
    Flask路由注册
    初识Flask
    微信小程序之基础使用
    celery任务队列
    文件处理小结
  • 原文地址:https://www.cnblogs.com/mekor/p/4021293.html
Copyright © 2011-2022 走看看