The purpose of the following code is to achieve a gradient background color In newer versions, it looks fine, but in macOS 10.12.4, the title of the button doesn't appear
- (void)setGradient:(NSArray<__kindof NSColor *> *)colorArr StartPoint:(CGPoint)startPoint EndPoint:(CGPoint)endPoint {
self.wantsLayer = YES;
CAGradientLayer *gradinentlayer = [CAGradientLayer layer];
NSMutableArray *array = [NSMutableArray array];
for (NSColor *color in colorArr) {
[array addObject:(id)color.CGColor];
}
gradinentlayer.colors = array;
gradinentlayer.startPoint = startPoint;
gradinentlayer.endPoint = endPoint;
gradinentlayer.frame = self.bounds;
[self.layer insertSublayer:gradinentlayer atIndex:0];
}
How do I make the title text appear, other than adding a subview? Any help would be appreciated!