// Mark: 2. 创建label
private func creatLabel(title: NSString)->UILabel{
/// 创建label
let titleL = UILabel(frame: CGRectMake(, , , )) titleL.text = title as String
titleL.textColor = UIColor.redColor()
titleL.backgroundColor = UIColor.yellowColor()
titleL.layer.cornerRadius = 10.0
titleL.layer.masksToBounds = true
titleL.textAlignment = NSTextAlignment.Center
titleL.font = UIFont.systemFontOfSize(16.0)
// 阴影
titleL.shadowColor = UIColor.cyanColor()
titleL.shadowOffset = CGSizeMake(-, )
// 省略方式
titleL.lineBreakMode = NSLineBreakMode.ByTruncatingTail
// titleL.adjustsFontSizeToFitWidth = true
titleL.numberOfLines = // 富文本
let attr = NSMutableAttributedString(string: "NSMutableAttributedStringNSMutableAttributedStringNSMutableAttributedString") attr.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(25.0), range: NSMakeRange(, ))
attr.addAttribute(NSForegroundColorAttributeName, value: UIColor.purpleColor(), range: NSMakeRange(, ))
titleL.attributedText = attr self.view.addSubview(titleL)
return titleL;
}

swift-UILabel的更多相关文章

  1. swift UILabel加载html源码

    @IBOutlet weak var content: UILabel! func setup(content:String){ self.content.preferredMaxLayoutWidt ...

  2. swift UILabel多行显示时 计算UILable的高度(可用于UILable高度自适应)

    代码如下 func heightForView(text:String, font:UIFont, width:CGFloat) -> CGFloat{ let label:UILabel = ...

  3. swift - UILabel的用法

    1.label的声明 class FirstyViewController: UIViewController { var label = UILabel()//初始化 override func v ...

  4. iOS -Swift 3.0 -UILabel属性大全

    昨天研究了一下苹果近两年新出的Swift语言,感觉学起来并不是很吃力,毕竟自己有过Objective-C的语言功底,所以各方面的属性控件还是一眼就可以认出的,只是Swift的写法与Objective- ...

  5. swift系统学习控件篇:UIbutton+UIlabel+UITextField+UISwitch+UISlider

    工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIButton+UILabel // // ViewController.swift // ...

  6. Swift的UILabel的一些属性

    let label = UILabel(frame: CGRectMake(,,,)) label.backgroundColor = UIColor.redColor() label.text = ...

  7. Swift - 通过叠加UILabel来实现混合的进度条

    Swift - 通过叠加UILabel来实现混合的进度条 效果 源码 https://github.com/YouXianMing/Swift-Animations // // MixedColorP ...

  8. Swift之控件-UIlabel

    let label = UILabel(frame:CGRect(x: 20,y: 100,width: 280,height: 40)) label.text = "理想接电话是否很沮丧和 ...

  9. 【Swift】UILabel 设置内边距

    前言 对应一个曾经开发 Android 的人来说,没有这些基础属性简直令人发指,还是表喷这个,认真写代码 - - # 声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnblo ...

  10. Swift - 文本标签(UILabel)的用法

    1,标签的创建 1 2 3 4 5 6 7 8 9 10 import UIKit class ViewController: UIViewController {     override func ...

随机推荐

  1. multiple build commands for output file

    在项目中  我们经常会碰到图片这方面的警告  虽然不影响运行 但是警告太多了也不是很好  其中 图片方面遇到的警告以下面的警告偏多:multiple build commands for output ...

  2. quartz定时任务中常用的cron表达式

    一:定时cron的格式,一个cron表达式有至少6个(也可能7个)有空格分隔的时间元素. 按顺序依次为: 1.秒(0~59) 2.分钟(0~59) 3.小时(0~23) 4.天(月(0~31,但是你需 ...

  3. 关于Eclipse中的一些基本知识

    Eclipse中寻找JRE的顺序是:vm参数指定的JRE--->elipse目录下的JRE--->操作系统中默认的JRE,利用这个特性也可以用vm参数来解决当本机安装有多个JRE的情况. ...

  4. ADO.NET通用数据库访问类

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. Extjs3笔记 fbar

    在项目中会遇到在grid右下角显示合计之类的显示. 之前使用过的方式: 1.用width强制顶过去. 2.利用css来控制. 弊端: 利用第一种方式:导致调整窗口大小时会导致合计不能根据窗体的大小变化 ...

  6. iOS项目里面如何清理缓存

    在正式讲解以前,请先看一下以下图片,在以下这款APP种设有清理缓存,开始我以为很复杂,在弄明白之后,其实就是几句代码就解决了.      在实际项目开发中,我们很多的文件都会缓存在沙盒里面,比如:照片 ...

  7. OC4_NSString操作

    // // main.m // OC4_NSString操作 // // Created by zhangxueming on 15/6/10. // Copyright (c) 2015年 zhan ...

  8. Server Error The server encountered an error and could not complete your request. 新建站点模版失败

    500 Server Error Error: Server Error The server encountered an error and could not complete your req ...

  9. 问题解决:使用angularjs、ionic框架如何实现返回上一页并刷新

    普通的js返回并刷新这里就不多说了,百度就有很多方法. 下面说的是使用了angularjs.ionic开发的一个手机app中使用的一个返回上一页并刷新的方法. 场景:回复的页面是单独的,点击保存回复后 ...

  10. myeclipse-8.6.0下载

    myeclipse老版本不分32位和64位,欢迎大家下载使用! 链接:http://pan.baidu.com/s/1dEJCxcl 密码:z1ga