UI之responder
来源:互联网 发布:排行榜java手机游戏 编辑:程序博客网 时间:2024/06/04 18:52
按钮响应事件
#import "MangoView.h"
//引入头文件#import "mainViewController.h"
@implementation MangoView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self costom];
}
return self;
}
- (void)costom{
UIView *aView = [[UIView alloc]initWithFrame:self.frame];
aView.backgroundColor = [UIColor greenColor];
[self addSubview:aView];
[aView release];
UIView *bView = [[UIView alloc]initWithFrame:CGRectMake(30, 40, 330, 250)];
bView.backgroundColor = [UIColor redColor];
[self addSubview:bView];
[bView release];
UIView *eView = [[UIView alloc]initWithFrame:CGRectMake(30, 330, 330, 300)];
eView.backgroundColor = [UIColor yellowColor];
[self addSubview:eView];
[eView release];
UIView *cView = [[UIView alloc]initWithFrame:CGRectMake(40, 40, 250, 100)];
cView.backgroundColor = [UIColor lightGrayColor];
[eView addSubview:cView];
[cView release];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(80, 30, 80, 40);
button.backgroundColor = [UIColor blackColor];
[button setTitle:@"button" forState:UIControlStateNormal];
[button setTitle:@"" forState:UIControlStateHighlighted];
[button addTarget:self action:@selector(bun) forControlEvents:UIControlEventTouchUpInside];
[cView addSubview:button];
UIView *dView = [[UIView alloc]initWithFrame:CGRectMake(40, 160, 250, 100)];
dView.backgroundColor = [UIColor lightGrayColor];
// userInteractionEnabled用户交互是否可用,YES可,NO不可
// dView.userInteractionEnabled = NO;
[eView addSubview:dView];
[dView release];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(80, 40, 80, 40);
[btn setTitle:@"Touch" forState:UIControlStateNormal];
[btn setTitle:@"" forState:UIControlStateHighlighted];
btn.backgroundColor = [UIColor brownColor];
[btn addTarget:self action:@selector(touch) forControlEvents:UIControlEventTouchUpInside];
[dView addSubview:btn];
}
- (void)touch{
NSLog(@"touch");
}
- (void)bun{
NSLog(@"button");
}
#import "mainViewController.h"
//引入头文件
#import "MangoView.h"
@interface mainViewController ()
@end
@implementation mainViewController
- (void)loadView{
[super loadView];
self.view = [[MangoView alloc]initWithFrame:self.view.frame];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
1 0
- UI之responder
- Responder
- IOS深入学习(25)之Responder object
- Responder对象
- first responder
- Responder object
- responder nextResponder
- Responder object
- responder chain
- 事件传递之响应链(Event Delivery: The Responder Chain)[译]
- 事件传递之响应链(Event Delivery: The Responder Chain)【转】
- Responder Objects and the Responder Chain
- iphone的responder chain
- IOS Responder Chain简析
- Responder Chain简析
- nextResponder与Responder Chain
- The Responder Chain
- Responder Chain简析
- APP存在的五大性能问题及解决办法
- How to choose the number of topics/partitions in a Kafka cluster?
- Android:控件WebView显示网页
- erlang中lists函数
- Android开发-使用eclipse将工程打成jar包
- UI之responder
- 如何进行java系统优化
- 多态性
- 如何在eclipse jee中检出项目并转换为Maven project,最后转换为Dynamic web project
- Top100案例参会总结
- java.lang.StackOverflowError: android.view.View.isLayoutDirectionInherited
- curl爬不到想要的结果,原因何在
- 太原UI设计师郭文军让【初学者】掌握web代码的标签及属性颜色的提示
- C# 进制之间的转换