//
// ViewController.m
// ButtonSetHighlightTest
//
// Created by 凌 陈 on 9/5/17.
// Copyright © 2017 凌 陈. All rights reserved.
//#import "ViewController.h"@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.// 实例化一个NSButtonNSButton *button = [[NSButton alloc] initWithFrame:CGRectMake(20, 20, 60, 30)];// 设置button normal状态图片[button setImage:[NSImage imageNamed:@"apress"]];// 设置button highlight状态图片[(NSButtonCell *)ll setHighlightsBy:NSContentsCellMask];button.alternateImage = [NSImage imageNamed:@"apress1"];// 设置图片铺满ll setImageScaling:NSImageScaleAxesIndependently];// 去掉button边框[button setBordered:NO];[button bezelStyle];// 设置响应事件button.target = self;button.action = @selector(buttonAction);// 将button加到view中[self.view addSubview:button];}- (void)setRepresentedObject:(id)representedObject {[super setRepresentedObject:representedObject];// Update the view, if already loaded.
}// button响应事件
-(void) buttonAction {NSLog(@"你按下了按键1!");
}@end
UIControlState
UIControlState
UIControlState
本文发布于:2024-01-29 17:29:16,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170652055817073.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |