To create a tri-colour view with the colours of the French flag in Swift, you can use a UIView
and set its backgroundColor
property to a UIColor
created from a CIColor
that represents the desired colour.
Here's an implementation of this solution:
main.swift1049 chars22 lines
Here we have created a new UIView
called triColourView
with a frame of 100x100
. We then create the UIColor
s for the blue, white, and red colours of the French flag using CIColor
.
Next, we divide the triColourView
into three equal parts using CGRect
s, and create a UIView
for each segment with the appropriate background colour, and add them to the triColourView
.
Finally, we have a new UIView
called triColourView
which now displays the French flag in tri-colour view!
gistlibby LogSnag