zoukankan      html  css  js  c++  java
  • swift 初见-6集合类型与Cocoa Touch混编

    // Playground - noun: a place where people can play
    
    import UIKit
    
    var str = "Hello, playground"
    // color与=号之间必须有个空格
    let colors =
    [
        "Air Force Blue":(red:93,green:138,blue:168),
        "Bittersweet":(red:254,green:111,blue:94),
        "Canary Yellow":(red:255,green:239,blue:0),
        "Dark Orange":(red:255,green:140,blue:0)
    ]
    var backView = UIView(frame: CGRectMake(0, 0,320.0,CGFloat(colors.count*50)))
    backView.backgroundColor=UIColor.blackColor()
    var index=0
    for (colorName,rgbTuple) in colors
    {
       var colorStripe=UILabel(frame: CGRectMake(0.0,CGFloat(index*50+5), 320, 40))
        colorStripe.backgroundColor=UIColor(
            red:CGFloat(rgbTuple.red), green:CGFloat(rgbTuple.green) , blue:CGFloat(rgbTuple.blue), alpha: 1.0
        )
        colorStripe
        
        var colorNameLabel=UILabel(frame: CGRectMake(0.0, 0.0,300, 40))
        colorNameLabel.font=UIFont(name:"Arial", size: 24.0)
        colorNameLabel.textColor=UIColor.blackColor()
        colorNameLabel.text=colorName
        colorStripe.addSubview(colorNameLabel)
        backView.addSubview(colorStripe)
        index++
    }
    backView
    
    
    
    
    var newbBackView=UIView(frame: CGRectMake(0,CGFloat(colors.count*5),320, CGFloat(colors.count*50)))
    newbBackView.backgroundColor=UIColor.orangeColor()
    index=0
    for(colorName,rgbTuple) in colors
    {
        var colorStripe=UILabel(frame: CGRectMake(0,CGFloat(index*50+5), 320, 40))
        colorStripe.backgroundColor=UIColor(red: CGFloat(rgbTuple.red), green: CGFloat(rgbTuple.green), blue: CGFloat(rgbTuple.blue), alpha: 0.5)
        colorStripe.text=colorName
        colorStripe.textAlignment=NSTextAlignment.Center
        index++
        newbBackView.addSubview(colorStripe)
    }
    newbBackView
  • 相关阅读:
    通过wireshark抓包来讲解HTTP中Connection: keep-alive头部的作用
    spring cloud连载第三篇补充之Zuul
    Redis管理各类型存储数据命令
    Redis管理key命令
    Redis命令
    Redis数据类型
    Redis配置文件
    Redis安装
    Redis简介
    SpringBoot项目报错Cannot determine embedded database driver class for database type NONE
  • 原文地址:https://www.cnblogs.com/lovelifeloveme/p/4066382.html
Copyright © 2011-2022 走看看