【发布时间】:2014-07-18 19:12:25
【问题描述】:
我正在通过覆盖 -(void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag 来更改插入点大小,但它无法处理第一次闪烁(当您移动插入点时,它会恢复正常)
我设法通过覆盖私有方法 - (void)_drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor 来处理第一次闪烁。
但这对我来说不是解决方案,因为覆盖私有方法将导致被 App Store 拒绝。我希望该应用程序出现在 App Store 中。我看到像 iAWriter 和 Writeroom 这样的应用程序有一个自定义插入点,它们在 App Store 中。
有谁知道他们是如何做到这一点的,或者有更好的方法而不是覆盖私有方法?
谢谢。
- (void)_drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor
{
aRect.size.width = 3.0;
[aColor set];
[NSBezierPath fillRect:aRect];
}
- (void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag
{
if(flag) {
aRect.size.width = 3.0;
[aColor set];
[NSBezierPath fillRect:aRect];
}
else {
[self setNeedsDisplayInRect:[self visibleRect] avoidAdditionalLayout:NO];
}
}
【问题讨论】:
-
flag 为 false 时,您是否尝试清除插入点区域(填充背景等)?
标签: cocoa customization nstextview caret