Mac应用开发中的用户界面图形与视频处理
1. 焦点环绘制
在Mac应用开发中,绘制焦点环时,通常会使用如下代码:
// draw the focus ring
NSSetFocusRingStyle(NSFocusRingOnly);
NSFrameRect([self bounds]);
不过,当使用CoreAnimation时,上述代码可能无法正常工作,焦点发光效果会被图层的内容矩形裁剪。好在OS X 10.7引入了新的API来绘制焦点环。若视图是第一响应者,系统会调用视图的 -focusRingMaskBounds 方法,通常在此方法中返回内容的边界矩形。之后,系统会调用 -drawFocusRingMask 方法来绘制焦点环的遮罩。以下是具体示例:
- (NSRect)focusRingMaskBounds
{
return [self bounds];
}
- (void)drawFocusRingMask
{
// we fill our bounds, so that's the mask for our focus rect
[[NSColor blackColor] setFill];
NSRectFill([self bounds]);
}
2. Cocoa图形基元
App Kit提供了一些基本类,用于封装颜色、颜色空间以及图形
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



