//Playground-noun:a Place where people can playImport Uikitvar str="Hello, playground."//there must be a space between the color and the = signlet colors =[ "Air Force Blue":(Red: the, Green:138, Blue:168), "Bittersweet":(Red:254, Green:111, Blue:94), "Canary Yellow":(Red:255, Green:239, Blue:0), "Dark Orange":(Red:255, Green: $, Blue:0)]var Backview= UIView (Frame:cgrectmake (0,0,320.0, CGFloat (colors.count* -)) Backview.backgroundcolor=Uicolor.blackcolor () var index=0 for(colorname,rgbtuple)inchcolors{var colorstripe=uilabel (Frame:cgrectmake (0.0, CGFloat (index* -+5), the, +)) 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, -, +)) Colornamelabel.font=uifont (Name:"Arial", Size:24.0) Colornamelabel.textcolor=Uicolor.blackcolor () Colornamelabel.text=colorname Colorstripe.addsubview (Colornamelabel) Backview.addsubview (colorstripe) Index++}backviewvar Newbbackview=uiview (Frame:cgrectmake (0, CGFloat (colors.count*5), the, CGFloat (colors.count* -)) Newbbackview.backgroundcolor=uicolor.orangecolor () index=0 for(colorname,rgbtuple)inchcolors{var colorstripe=uilabel (Frame:cgrectmake (0, CGFloat (index* -+5), the, +)) 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
Swift-6 collection type and cocoa touch mixed