Mac专题macOS开发MacOS开发 技术集锦

macOS开发-知识点总结

2016-12-09  本文已影响101人  wright
    NSImage *backgroundImage = [NSImage imageNamed:@"图片名称"];
    backgroundImage.size = self.bounds.size;
    [backgroundImage lockFocus];
    
    NSColor* backgroundColor = [NSColor colorWithPatternImage:backgroundImage];
    [backgroundColor set];
    NSRectFill(self.bounds);
    
    [backgroundImage unlockFocus];
    
    // draw your new image
    [backgroundImage drawInRect:self.bounds
                       fromRect:NSZeroRect // 绘制整张图片
                      operation:NSCompositeSourceOver
                       fraction:1.0f];
    -(NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender{
    NSPasteboard *pboard = [sender draggingPasteboard];
    
    if([[pboard types] containsObject:NSFilenamesPboardType])
    {
        return NSDragOperationCopy;
    }
        return NSDragOperationNone;
    }
    
      -(BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender
    {
        return YES;
    }

    -(BOOL)performDragOperation:(id<NSDraggingInfo>)sender
    {
        NSArray *filePaths =[[sender draggingPasteboard] propertyListForType:NSFilenamesPboardType];
        // 利用拖拽文件进行相应操作
    }
    
    -(void)concludeDragOperation:(id<NSDraggingInfo>)sender
    {
        //拖拽结束
    }
@interface NSWindow (WFFullScreen)

- (BOOL)isFullScreen;

@end

@implementation NSWindow (BFFullScreen)

- (BOOL)isFullScreen
{
    return (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask);
}

@end
上一篇下一篇

猜你喜欢

热点阅读