O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required