UIButton / UIControl

一、初始化     UIButton *button = [ UIButton buttonWithType : UIButtonTypeCustom ];     [ self . view addSubview :button];   // 添加到视图

  •     UIButtonTypeCustom  -  自定义风格(按钮的默认颜色是白色)
  •   UIButtonTypeSystem  -  系统默认样式(默认颜色为蓝色)
二、设置button 属性 (1)设置button的位置(frame)     button. frame = CGRectMake (2 0 , 20 , 5 0 , 5 0 ); (2)设置button背景 1、背景色
  • 写法一:
    button. backgroundColor = [ UIColor clearColor ];
  • 写法二:
    [button setBackgroundColor :[ UIColor blueColor ]]; 2、设置图片
  • 填充图片:
    [button setImage :[ UIImage imageNamed : @"6.jpeg" ] forState : UIControlStateNormal ];
  • 背景图片:
    [button setBackgroundIma


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部