2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Swift]UIColor SampleColor

Last updated at Posted at 2015-09-08

色の参考
iOS Simulator.png

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

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?