[Swift]UIColor SampleColor

6574 단어 Swift
색상 참조

tableView
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell")

        let colors: [(color: UIColor, text: String)] = [
            (UIColor.blackColor(),"blackColor"),
            (UIColor.darkGrayColor(),"darkGrayColor"),
            (UIColor.lightGrayColor(),"lightGrayColor"),
            (UIColor.whiteColor(),"whiteColor"),
            (UIColor.grayColor(),"grayColor"),
            (UIColor.redColor(),"redColor"),
            (UIColor.greenColor(),"greenColor"),
            (UIColor.blueColor(),"blueColor"),
            (UIColor.cyanColor(),"cyanColor"),
            (UIColor.yellowColor(),"yellowColor"),
            (UIColor.magentaColor(),"magentaColor"),
            (UIColor.orangeColor(),"orangeColor"),
            (UIColor.purpleColor(),"purpleColor"),
            (UIColor.brownColor(),"brownColor"),
            (UIColor.clearColor(),"clearColor")]

        cell.textLabel?.text = colors[indexPath.row].text
        cell.backgroundColor = colors[indexPath.row].color

        if (cell.backgroundColor == UIColor.blackColor())
        {
            cell.textLabel?.textColor = UIColor.whiteColor()
        }

        return cell
    }
참조 소스
https://github.com/senseiswift/UIColorSample

좋은 웹페이지 즐겨찾기