开发sketch插件

1、git安装模板  git clonehttps://github.com/MagicSketch/XcodeTemplate-SketchPlugin.git~/Library/Developer/Xcode/Templates/Sketch\ Plugin








**************************************************************************************
#import

#import

@interface MyViewController : NSViewController

    @property (weak) IBOutlet WebView *myWebView;

@end

**********************************************************************************



*******************************************************************

#import "MyViewController.h"

@interface MyViewController ()

@end

@implementation MyViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do view setup here.

    NSString *urlString = @"https://www.baidu.com";

    [[self.myWebView  mainFrame ] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];

}

@end

****************************************************************************



****************************************************************************

@property (nonatomic, strong) NSWindow *myWindow;


- (void)onSelectionChange:(NSArray *)selection {

    //[_panelController selectionDidChange:selection];

    NSLog(@"selection");

    NSRect frame = CGRectMake(0, 0, 1880, 800);

    NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask;

    self.myWindow = [[NSWindow alloc] initWithContentRect:frame styleMask:style backing:NSBackingStoreBuffered defer:YES];

    //self.myWindow= [[NSWindow alloc] init];

    //2.设置窗口根控制器

    //2.1通过xib创建窗口的根控制器:initWithNibName

    //NibName:xib名称

    // MyViewController *vc = [[MyViewController alloc] initWithNibName:@"MyViewController"bundle:nil];

    //MyViewController *vc = [[MyViewController alloc] init];

    MyViewController *vc = [[MyViewController alloc] initWithNibName:@"MyViewController"bundle:[NSBundle bundleForClass:[self class]]];

    self.myWindow.contentViewController= vc ;

    //3.显示窗口

    [self.myWindow makeKeyAndOrderFront:self];

}

******************************************************************

你可能感兴趣的:(开发sketch插件)