zoukankan      html  css  js  c++  java
  • IOS开发系列之Swift_UI_Lab

    import UIKit

    class ViewController: UIViewController {

        //这里做个lab声明

        var exampleLab : UILabel!

        override func viewDidLoad() {

            super.viewDidLoad()

            //调用makeUI

            makeUI()

            // Do any additional setup after loading the view, typically from a nib.

        }

        //写一个方法哦

        private func makeUI() {

            //初始化lab 

            self.exampleLab = UILabel.init()

            //給他frame

            self.exampleLab.frame = CGRectMake(100, 100, 200, 40)

            //lab 赋值

            self.exampleLab.text = "我仅仅是一个lab我仅仅是一个lab我仅仅是一个lab我仅仅是一个lab"

            //设置lab居中

            self.exampleLab.textAlignment = .Center

            //设置lab 字体大小

            self.exampleLab.font = UIFont.systemFontOfSize(13)

            //设置lab的字体颜色

            self.exampleLab.textColor = UIColor(red: 12/255.0, green: 122/255.0, blue: 222/255.0, alpha: 1)

            //设置lab 的背景颜色

            self.exampleLab.backgroundColor = UIColor.blackColor()

            //給lab 添加圆角(角度为lab 高度的一半的时候会是半圆)

            self.exampleLab.layer.cornerRadius = 20

            //多余的部分切掉

            self.exampleLab.clipsToBounds = true

            //设置lab 的字体阴影颜色

            //self.exampleLab.shadowColor = UIColor.redColor()

            //设置阴影偏移

            //self.exampleLab.shadowOffset = CGSizeMake(1, 1)

            //设置lab 的分行

            self.exampleLab.numberOfLines = 0

            //添加lab 到view上

            self.view .addSubview(self.exampleLab)

        }

        

        override func didReceiveMemoryWarning() {

            super.didReceiveMemoryWarning()

            // Dispose of any resources that can be recreated.

        }

    }

  • 相关阅读:
    linux下vim的安装及其设置细节
    vm虚拟机下ubuntu连接上ssr
    文件写入-结构体排序
    利用链表进行报数游戏
    链表——尾插法
    C#设计模式总结
    C#设计模式(20)——策略者模式(Stragety Pattern)
    Autofac在项目中应用的体会,一个接口多个实现的情况
    C#设计模式(1)——单例模式
    jquery.js与sea.js综合使用
  • 原文地址:https://www.cnblogs.com/godlovexq/p/5278496.html
Copyright © 2011-2022 走看看