zoukankan      html  css  js  c++  java
  • Swift

    //: Playground - noun: a place where people can play
    
    import UIKit
    
    // 数据源
    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),
        "Electric Violet":(red:255, green:140, blue:0),
        "Fern":(red:113, green:188, blue:120),
        "Gamboge":(red:228, green:155, blue:15),
        "Hollywood Cerise":(red:244, green:0, blue:161),
        "Icterine":(red:252, green:247, blue:94),
        "Jazzberry Jam":(red:165, green:11, blue:94),
    ]
    
    // 创建一个UIView用于显示
    var rect = CGRectMake(0, 0, 320, (CGFloat)(colors.count * 50));
    var backView = UIView(frame:rect)
    backView.backgroundColor = UIColor.blackColor()
    backView
    
    var index = 0
    for (colorName, rgbTuple) in colors
    {
      // 创建UILabel用来显示颜色, 并将其放在view上
        var labelRect = CGRectMake(0, (CGFloat)(index * 50 + 5), 320, 40)
        var colorStripe = UILabel(frame: labelRect)
        colorStripe.text = colorName
        colorStripe.backgroundColor =
            UIColor(
                red: (CGFloat)(rgbTuple.red) / 255.0,
                green: (CGFloat)(rgbTuple.green) / 255.0,
                blue: (CGFloat)(rgbTuple.blue) / 255.0,
                alpha: 1.0
        )
        colorStripe
        backView.addSubview(colorStripe)
        index++
    }
    backView
    

      

  • 相关阅读:
    待重写
    待重写
    待重写
    ReflectionUtils使用
    kafka消费组、消费者
    待重写
    Map接口常用实现类学习
    利用httpClient发起https请求
    sql常用格式化函数及字符串函数
    method reference
  • 原文地址:https://www.cnblogs.com/Rinpe/p/5050808.html
Copyright © 2011-2022 走看看