博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UIKit 框架之UIButton
阅读量:7087 次
发布时间:2019-06-28

本文共 2120 字,大约阅读时间需要 7 分钟。

列举几个稍微难点的属性,其他的方法属性都好理解,可以参照UIButton.h

////  ViewController.m//  UIButton////  Created by City--Online on 15/5/19.//  Copyright (c) 2015年 XQB. All rights reserved.// #import "ViewController.h" @interface ViewController ()@property(nonatomic,strong) UIButton *btn1;@end @implementation ViewController - (void)viewDidLoad {    [super viewDidLoad];          //    typedef NS_ENUM(NSInteger, UIButtonType) {//        UIButtonTypeCustom = 0,                         // no button type//        UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0),  // standard system button//        //        UIButtonTypeDetailDisclosure,//        UIButtonTypeInfoLight,//        UIButtonTypeInfoDark,//        UIButtonTypeContactAdd,//        //        UIButtonTypeRoundedRect = UIButtonTypeSystem,   // Deprecated, use UIButtonTypeSystem instead//    };    _btn1=[UIButton buttonWithType:UIButtonTypeSystem];    //确定按钮高亮时是否改变阴影的Bool值.默认时NO,当为YES时,阴影在雕刻与浮雕感之间变化(差不多就是去正常offset的相反数作为新的offset)     _btn1.reversesTitleShadowWhenHighlighted=YES;         //EdgeInsets边缘填充 类似CSS盒子模型中的内边距padding    _btn1.imageEdgeInsets=UIEdgeInsetsMake(30, 10, 0, 0);    _btn1.contentEdgeInsets=UIEdgeInsetsMake(30, 40, 0, 0);    _btn1.titleEdgeInsets=UIEdgeInsetsMake(20, 20, 0, 0);    UIImage *img=[UIImage imageNamed:@"1.jpg"];    //UIButton里面包含一个UILabel和一个UIImageView    [_btn1 setImage:img forState:UIControlStateNormal];    [_btn1 setTitle:@"按钮" forState:UIControlStateNormal];         //设置控件内容水平对齐方式    _btn1.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;         //确定当按钮高亮时图片是否改变的BOOL值,为真时图片随按钮高亮而高亮//    _btn1.highlighted=YES;    _btn1.adjustsImageWhenHighlighted=YES;         //确定当按钮高亮时图片是否改变的BOOL值,为真时图片随按钮失效而变暗//    _btn1.enabled=NO;    _btn1.adjustsImageWhenDisabled=YES;         //控制当按钮按下时是否闪光的BOOL值.默认NO,YES时按下会有白色光点.图片和按钮事件的不会因闪光改变.    _btn1.showsTouchWhenHighlighted=YES;    _btn1.frame=CGRectMake(20, 100, 200, 200);    _btn1.backgroundColor=[UIColor redColor];    [self.view addSubview:_btn1];     } - (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.} @end

转载地址:http://tlbql.baihongyu.com/

你可能感兴趣的文章
Hyper-V安装图解
查看>>
ORACLE 树型层次结构查询
查看>>
关于Java Web的问题
查看>>
FreeBSD第一天<建立FreeBSD基础环境>
查看>>
ddr2引脚
查看>>
fail2ban说明、安装、配置、测试
查看>>
webpack.config.js
查看>>
iostat 命令详解
查看>>
[charles petzold]windows程序设计第六版
查看>>
模拟话机关闭hold功能
查看>>
用SSG做IPsec***做成近似2层连接
查看>>
Spark Catalyst 的实现分析
查看>>
Windows Azure Pack与VMware VRA 对比(三)VRA角色简介及基础配置
查看>>
vue设置页面滚动
查看>>
HP刀片服务器系统Flex-10 VC配置与VMware vSphere网络设计
查看>>
《D3.js数据可视化实战手册》即将上市!
查看>>
用Nginx配置https加密站点
查看>>
Sersync数据同步
查看>>
hsrp+track
查看>>
Spring mvc 在一个定时器类里实现多个定时器任务
查看>>