当前位置: 首页 > news >正文

ppt素材网站建设流程图/免费智能seo收录工具

ppt素材网站建设流程图,免费智能seo收录工具,互联网营销公司排行榜,服装设计网UIButton和UILable的学习 从今天开始学习基本控件,先从按钮和标签开始。 1.UIButton相关属性 构造方法(UIButton(type:UIButtonType.InfoDark))位置和大小 :frame背景颜色 :backgroundColor前景颜色 : tintColor文字…

UIButton和UILable的学习

从今天开始学习基本控件,先从按钮和标签开始。

1.UIButton相关属性

  • 构造方法(UIButton(type:UIButtonType.InfoDark))
  • 位置和大小 :frame
  • 背景颜色 :backgroundColor
  • 前景颜色 : tintColor
  • 文字 : setTitle
  • 添加点击事件 :func addTarget(target: AnyObject?, action: Selector, forControlEvents controlEvents: UIControlEvents)
  • 标记 : tag
  • 按钮的圆角 : layer.masksToBounds = true
  • 圆角的半径 :layer.cornerRadius
  • 边框的颜色:ayer.borderColo
  • 边框的宽度 :layer.borderWidth

2.代码的实现

let btn1 = UIButton(type:UIButtonType.InfoDark)btn1.frame = CGRectMake(130, 80, 40, 40)let btn2 = UIButton(type:UIButtonType.RoundedRect)//设置按钮的位置和大小btn2.frame = CGRectMake(80, 180, 150, 44)//设置按钮的背景颜色btn2.backgroundColor = UIColor.purpleColor()//设置按钮的前景颜色btn2.tintColor = UIColor.yellowColor()//设置按钮的文字btn2.setTitle("Press ON", forState: .Normal)//设置按钮的点击事件btn2.addTarget(self, action: #selector(UIBUttonViewController.buttonTag(_:)), forControlEvents: UIControlEvents.TouchUpInside)//为按钮设置标记btn2.tag = 20let btn3 = UIButton(type:UIButtonType.RoundedRect)btn3.backgroundColor = UIColor.brownColor()btn3.tintColor = UIColor.whiteColor()btn3.setTitle("Press Off", forState: .Normal)btn3.frame = CGRectMake(80, 280, 150, 44)btn3.layer.masksToBounds = true//设置按钮的圆角半径为10btn3.layer.cornerRadius = 5//设置按钮的边框宽度为4btn3.layer.borderWidth = 1//设置按钮的边框颜色btn3.layer.borderColor = UIColor.lightGrayColor().CGColorself.view.addSubview(btn1)self.view.addSubview(btn2)self.view.addSubview(btn3)/***按钮的事件处理**/func buttonTag(btn:UIButton) {let alter = UIAlertController(title: "Information",message: "Button Event",preferredStyle: UIAlertControllerStyle.Alert)let oKAction = UIAlertAction(title: "OK",style: UIAlertActionStyle.Default,handler: nil)alter.addAction(oKAction)self.presentViewController(alter, animated: true, completion: nil)}

3 .UILable的相关属性

  • 内容 :text
  • 字体:font
  • 文字的阴影颜色 :shadowColor
  • 文字的阴影在横向和纵向的偏移距离:shadowOffset
  • 文字的对其的方式:textAlignment
  • 标签文字的颜色 :textColor
  • 标签背景颜色:backgroundColor

4.UILable的代码实现

        let rect = CGRectMake(20, 440, 280, 80)   let lable = UILabel(frame: rect)lable.text = "Hello Lable"let font = UIFont(name: "宋体",size: 12)lable.font = font//设置文字的阴影颜色lable.shadowColor = UIColor.lightGrayColor()//设置标签文字的阴影在横向和纵向的偏移距离lable.shadowOffset = CGSizeMake(2,2)//设置文字的对其的方式lable.textAlignment = NSTextAlignment.Center//设置标签文字的颜色lable.textColor = UIColor.purpleColor()//紫色//设置标签的背景颜色为黄色lable.backgroundColor = UIColor.yellowColor()

今天就学习这两个控件。
代码地址:这里写链接内容

相关文章:

  • 沈阳做网站seo/互联网营销的方法有哪些
  • 长沙市网站制作公司/互联网网络推广公司
  • 海南专业做网站的公司/互联网全网推广
  • 查询网站mx记录/互联网推广销售
  • 重庆网站建设技术支持重庆互联网/十大广告联盟
  • 吉安网站制作/互联网站
  • b2b大型网站建设/淮北网站建设
  • 网站建设找美橙互联/常德今日头条新闻
  • 济南网站建设域名注册/产品互联网推广
  • 专业的网店交易平台/互联网优化
  • 为什么做可信网站/市场推广方案模板
  • 青岛的互联网企业/天津seo招聘