Hi David Thank you! Your point is correct.
Cheers Yilei He On 21 Feb 2017, 8:48 AM +1100, David Duncan <[email protected]>, wrote: > > > On Feb 20, 2017, at 1:44 PM, Yilei He <[email protected]> wrote: > > > > My whole view's code: > > import Cocoa > > > > class GradientBackgroundView: NSView { > > > > > > override func draw(_ dirtyRect: NSRect) { > > let gradient = NSGradient(colors: [ > > NSColor(calibratedWhite: 0.96, alpha: 1), > > NSColor(calibratedWhite: 0.84, alpha: 1) > > ]) > > > > gradient?.draw(in: dirtyRect, angle: 270) > > This is your problem, you need to use the view.bounds here, not the > dirtyRect. The dirtyRect is a subregion of the bounds that needs to be > redrawn, but your code is basically doing the equivalent of drawing the > entire view into whatever dirtyRect you happen to get. > > > > > let path = NSBezierPath() > > path.move(to: NSPoint(x: 0, y: 0)) > > path.line(to: NSPoint(x: dirtyRect.maxX, y: 0)) > > NSColor.darkGray.setStroke() > > path.stroke() > > } > > > > } > > > > Cheers > > Yilei He > > > > On 21 Feb 2017, 04:18 +1100, David Duncan <[email protected]>, wrote: > > > > > > > On Feb 20, 2017, at 2:41 AM, Yilei He <[email protected]> wrote: > > > > > > > > Hi > > > > > > > > In my UI design, I have a custom NSView which only draws a NSGradient > > > > in draw(in:) method. I also have a NSTextField next to this custom > > > > view. Every time when text field is focused, the focus ring animates > > > > and leave a set of mark(animation tracks) on the custom view. > > > > > > Can you share your draw(in:) implementation? > > > > > > > > > > > After I tested this for a while, I found that the focus ring only > > > > leaves marks on gradient. > > > > > > > > Can anyone give a solution to remove the mark? > > > > > > > > Thanks > > > > Yilei He > > > > > > > > > > > > _______________________________________________ > > > > > > > > Cocoa-dev mailing list ([email protected]) > > > > > > > > Please do not post admin requests or moderator comments to the list. > > > > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > > > > > > > Help/Unsubscribe/Update your Subscription: > > > > https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com > > > > > > > > This email sent to [email protected] > > > > > > -- > > > David Duncan > > > > > -- > David Duncan > _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
