• UIButton


    一、UIButton的基本属性

    UIButton * button=[UIButton buttonWithType:UIButtonTypeCustom];//button的样式

    button.frame=CGRectMake(i%2*btnView.width/2,i/2*(btnView.height)/2, btnView.width/2, (btnView.height)/2);

    button.layer.borderWidth=0.5;//button的边框宽度

    button.layer.borderColor=[UIColor lightGrayColor].CGColor;//button的边框颜色

    button.titleLabel.font=[UIFont systemFontOfSize:14];

    button.tag=i;

    button.titleLabel.textAlignment=NSTextAlignmentCenter;

    [button setImage:[UIImage imageNamed:imgArr[i]] forState:UIControlStateNormal];

    [button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];

    [button setTitle:funArr[i] forState:UIControlStateNormal];

    [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];

    二、自定义的button

    -(CGRect)imageRectForContentRect:(CGRect)contentRect
    {
    return CGRectMake(self.width/2-self.height/4.0, 5, self.height/2, self.height/2);
    }

    -(CGRect)titleRectForContentRect:(CGRect)contentRect
    {
    return CGRectMake(0, self.height-18, self.width, 20);
    }

    - (void)setTitle:(NSString *)title forState:(UIControlState)state
    {
    self.titleLabel.textAlignment=NSTextAlignmentCenter;
    [super setTitle:title forState:state];
    }

  • 相关阅读:
    autocomplete
    ORM组件 ELinq (一)首航之旅
    ORM组件 ELinq 系列
    Jet 驱动对CRUD的支持
    ORM组件 ELinq 更新日志
    年度开源力作ORM组件 ELinq诞生了
    Excel 连接字符串详解
    国内开源ORM组件 ELinq正式版发布
    Firebird 问题总结
    ORM组件 ELinq (二) 映射配置之Table
  • 原文地址:https://www.cnblogs.com/momosmile/p/4633266.html
Copyright © 2020-2023  润新知