To create a view in Swift with a red background color of size 100 for both width and height, you can use the following code:
main.swift109 chars3 lines
This creates a view called 'myView' with a frame of CGRect(x: 0, y: 0, width: 100, height: 100)
which sets the origin to (0,0) and the width and height to 100. We then set the background color of the view to UIColor.red
which will give it a red background.
You can add this view to your current view hierarchy using:
main.swift24 chars2 lines
Where view
is the parent view that you want to add the myView
to.
gistlibby LogSnag