Focus Rings

When a view has the focus (which just means that it is the first responder), its appearance changes. For text input controls this is generally indicated with a blue ring around the control. For table views, the selection highlight may change from gray to blue.

Cocoa makes it very easy to draw the focus ring. Simply implement this method and property. Add them to the // MARK: - First Responder section.

o​v​e​r​r​i​d​e​ ​f​u​n​c​ ​d​r​a​w​F​o​c​u​s​R​i​n​g​M​a​s​k​(​)​ ​{​
 ​ ​ ​ ​N​S​B​e​z​i​e​r​P​a​t​h​.​f​i​l​l​R​e​c​t​(​b​o​u​n​d​s​)}o​v​e​r​r​i​d​e​ ​v​a​r​ ​f​o​c​u​s​R​i​n​g​M​a​s​k​B​o​u​n​d​s​:​ ​N​S​R​e​c​t​ ​{​
 ​ ​ ​ ​r​e​t​u​r​n​ ​b​o​u​n​d​s}

Now your users can see which die they will be changing. ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.