Mac_03_窗口顶置

该工具允许用户在Mac上将代码窗口始终保持顶置,同时保持代码高亮状态,支持黑白背景切换、窗口缩放和图片选择。使用Git进行项目初始化、提交和更新操作,并提供了GitHub仓库链接。
摘要由CSDN通过智能技术生成

功能描述: 

1. 可以把代码复制过来,并保持原来的高亮状态

2. 提供黑 白两种不同的背景状态切换

3. 支持窗口放大和缩小

4. 最重要的是: 该窗口一直置顶(当不再需要了可以按command + h 隐藏或退出程序)

5. 支持选择图片(比如代码的截图)



效果如下:



代码如下:

//
//  ViewController.m
//  mac_02_window
//
//  Created by beyond on 2018/6/5.
//  Copyright © 2018年 beyond. All rights reserved.
//

#import "ViewController.h"
#import <Quartz/Quartz.h>
@interface ViewController()<NSWindowDelegate>
{
    NSWindow *_win;
    NSTextView *_textView;
    NSScrollView *_scrollView;
    
    NSButton *_switchBtn;
    NSButton *_chooseImgBtn;
    NSImageView *_imgView;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    NSApplication* app = [NSApplication sharedApplication];
    
    //Create the main window
    NSRect rc = NSMakeRect(750, 1, 600, 350);
    NSUInteger uiStyle = NSTitledWindowMask | NSResizableWindowMask | NSClosableWindowMask;
    NSBackingStoreType backingStoreStyle = NSBackingStoreBuffered;
    NSWindow* win = [[NSWindow alloc] initWithContentRect:rc styleMask:uiStyle backing:backingStoreStyle defer:NO];
    [win setTitle:@"代码->顶置"];
    [win makeKeyAndOrderFront:win];
    
    //    给window添加一个NSTextField
    NSTextView *textField = [[NSTextView alloc]initWithFrame:win.contentView.frame];
    
//    textField.backgroundColor = [NSColor colorWithRed:29/255.0 green:30/255.0 blue:25/255.0 alpha:1];

    textField.backgroundColor = [NSColor colorWithRed:29/255.0 green:30/255.0 blue:25/255.0 alpha:1];
    
    tex
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值