• UIButton 详解


     1 UIButton *bt = [UIButton buttonWithType:UIButtonTypeContactAdd];// UIButtonTypeCustom, UIButtonTypeRoundedRect; //
     2     [bt setTitle:@"myButton" forState:UIControlStateNormal];        // 普通状态
     3     [bt setTitle:@"Button1" forState:UIControlStateHighlighted];    // 触摸时
     4     [bt setTitle:@"disButton" forState:UIControlStateDisabled];     // 无效时
     5     [bt setTitleColor:[UIColor redColor] forState:UIControlStateNormal];    // 普通状态下的字体颜色
     6     
     7     bt.titleLabel.font = [UIFont boldSystemFontOfSize:24];  // 按钮字体
     8     bt.titleLabel.shadowOffset = CGSizeMake(1, 1);
     9     bt.titleLabel.shadowColor = [UIColor redColor];
    10     
    11     
    12     [bt setImage:[UIImage imageNamed:@"normal.png"] forState:UIControlStateNormal];
    13     // 普通状态下图片,只在UIButtonTypeCustom,UIButtonTypeRoundedRect下有效
    14     [bt setBackgroundImage:[UIImage imageNamed:@"background.png"] forState:UIControlStateNormal]; // 设置背景图
    15     
    16     UIEdgeInsets insets;    // 设置按钮内部图片间距
    17     insets.top = insets.bottom = insets.right = insets.left = 10;
    18     bt.contentEdgeInsets = insets;
    19     
    20     bt.titleEdgeInsets = insets;    // 标题间距
    21     
    22     [bt addTarget:self
    23            action:@selector(click:)
    24  forControlEvents:UIControlEventTouchUpInside]; // 添加事件响应
  • 相关阅读:
    easycom HBuilderX 2.5.5起支持easycom组件模式
    我们为什么需要async/await ?
    封装uni.request请求
    uniapp 更新
    uniapp中plus的使用
    uniapp 自适应不同比例的屏幕
    npm 设置淘宝镜像、nrm、nodemon
    uniapp之nvue入坑
    Android平台签名证书(.keystore)生成指南
    day 37 数据库MySQL的进一步认识
  • 原文地址:https://www.cnblogs.com/sell/p/2891769.html
Copyright © 2020-2023  润新知