Contents
  1. 1. Xmas
  2. 2. How it works
    1. 2.1. Swift
    2. 2.2. DVTKit
    3. 2.3. NSVisualEffectView
  3. 3. Reference

Christmas is when we I have the most special feeling. The cool air, the snow, the reunion, the church bell ringing, …


(From google)

It ‘s beginning to look a lot like Christmas. First with Xcode

Xmas

Xmas is an Xcode plugin that shows Xmas picture along with wishing message whenever a build succeeds

How it works

Swift

  • Try to do much of the job in Swift as possible

DVTKit

  • Xcode uses DVTBezelAlertPanel to display alert. So we swizzle its initWithIcon:message:parentWindow:duration:
  • DVTBezelAlertPanel is from DVTKit. I thought about importing run time header and just extension it. But I find swizzling in Objective C a much more easier solution

NSVisualEffectView

  • It seems that NSImage added to the panel ‘s NSVisualEffectView had it template set to YES again, hence causing the image into template color with the panel background color
  • This happens in the init method. So we must change template back to NO after init happens
1
2
3
4
5
6
7
8
9
10
- (id)xmas_initWithIcon:(id)icon
message:(NSString *)message
parentWindow:(id)parentWindow
duration:(double)duration {
[self xmas_initWithIcon:image message:gift.message parentWindow:parentWindow duration:duration];

image.template = NO;

return self;
}

And, Merry Christmas to you and your family

Reference

Contents
  1. 1. Xmas
  2. 2. How it works
    1. 2.1. Swift
    2. 2.2. DVTKit
    3. 2.3. NSVisualEffectView
  3. 3. Reference