Drawing in iOS - Part 3: Challenge: Customize | Ray Wenderlich Videos

Style your own custom button through this hands-on challenge

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4659-drawing-in-ios/lessons/3

Hi Caroline,

Just a quick question…how does the closeButton (pre-challenge and pre-stylizing) instantiate its frame. I see the initial contructor with (type:) and the constraints but where is the position and size?


@sean_smith - take another look at formatCloseButton(in:) in SamplesTableViewController.swift. As well as being the initial constructor, the method contains all the constraints necessary for position and size.

There are width and height constraints of 50 and top and right constraints anchoring the button to the top right.

formatCloseButton(in:) is called by tableView(_:didSelectRowAt:) when the row is selected by the user, just before the new controller is presented.