Graphics Reference
In-Depth Information
NSDateComponents *components = [calendar components :units
fromDate :[ NSDate date ]];
//set hours
[ self setDigit :components. hour / 10 forView : self .digitViews[ 0 ]];
[ self setDigit :components. hour % 10 forView : self .digitViews[ 1 ]];
//set minutes
[ self setDigit :components. minute / 10 forView : self .digitViews[ 2 ]];
[ self setDigit :components. minute % 10 forView : self .digitViews[ 3 ]];
//set seconds
[ self setDigit :components. second / 10 forView : self .digitViews[ 4 ]];
[ self setDigit :components. second % 10 forView : self .digitViews[ 5 ]];
}
@end
As you can see from Figure 4.18, it works, but the digits look blurry. It seems that the
default kCAFilterLinear option has failed us.
Figure 4.18 A blurry clock display, caused by the default kCAFilterLinear scaling
To get the crisp digits shown in Figure 4.19, we just need to add the following line to the
for…in loop in our program:
view. layer . magnificationFilter = kCAFilterNearest ;
Search WWH ::




Custom Search