这是代码:
#import "customSlIDerCell.h"@implementation customSlIDerCell- (voID)drawKnob:(NSRect)knobRect { NSImage * knob = knobImage; [[self controlVIEw] lockFocus]; [knob compositetoPoint:NSMakePoint(knobRect.origin.x,knobRect.origin.y+knobRect.size.height) operation:NSCompositeSourceOver];[[self controlVIEw] unlockFocus];}- (voID)drawbarInsIDe:(NSRect)rect flipped:(BOol)flipped {rect.size.height = 8; NSRect leftRect = rect; leftRect.origin.x=0; leftRect.origin.y=2; leftRect.size.wIDth = knobrect.origin.x + (knobrect.size.wIDth); [leftbarImage setSize:leftRect.size]; [leftbarImage drawInRect:leftRect fromrect: NSZeroRect operation: NSCompositeSourceOver fraction:1]; NSRect rightRect = rect; rightRect.origin.x=0; rightRect.origin.y=2; rightRect.origin.x = knobrect.origin.x; [rightbarImage setSize:rightRect.size]; [rightbarImage drawInRect:rightRect fromrect: NSZeroRect operation: NSCompositeSourceOver fraction:1];}
啊,我很亲密.关于为什么会发生这种情况以及如何解决它的任何帮助将不胜感激,谢谢!
解决方法 好的,所以它已经弄清楚了.显然滑块试图变得聪明,只能在旋钮的位置画画.所以显然我必须通过覆盖滑块类中的setNeedsdisplayInRect来使rect一直无效.#import "customSlIDer.h"@implementation customSlIDer-(voID)setNeedsdisplayInRect:(NSRect)invalIDRect{ [super setNeedsdisplayInRect:[self bounds]];}@end总结
以上是内存溢出为你收集整理的objective-c – 自定义NSSliderCell全部内容,希望文章能够帮你解决objective-c – 自定义NSSliderCell所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)