学习笔记--@property和@sythesize,方法重写及回顾

深入探讨iOS应用开发过程中的关键元素,包括界面设计、布局优化、交互体验提升及代码最佳实践,确保构建出高效、美观且用户体验卓越的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

@property

@sythesize

当.h文件变量命名以_开头,一起使用相当于@property


用@sythesize时,可以重写getter或setter方法,以满足具体需要


方法重写:

1、重写系统的方法:如init、dealloc等

2、重写自己的方法:如子类需要在父类的一些方法上增加某些东西


回顾:UILabel   UIImageView  UITextField   UIView  UIButton  Timer

未掌握:UIButton  Timer  UILabel


已掌握:@property   @sythesize等



未掌握总结:
UILabel *lb = [[UILabel alloc]initWithFrame:CGRectMake(100,100,100,100)];
lb.text = @"god bless you";
lb.textColor = [UIColor redColor];
lb.font = [UIFont fontOfSize:26];
lb.shadowColor = [UIColor purpleColor];
lb.shadowSize = CGSizeMake(2,2);//写错了。。。。。。应是shadowOffSet
lb.numberOfLines = 0;//忘记
lb.textAligment = NSTextAligment;//忘记,以前错过多次
[self.window addSubview];

UIButton *btn = [UIButton buttonWithType:UI];//buttonWithType后面......
btn.frame = CGRectMake(100,100,100,100);
btn.backgroundColor = [UIColor grayColor];//这句忘记了(默认透明颜色,大部分需要写)
[btn setTitle:@"click" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(method) forControlEvents:UIControlEventTouchUpInside];//记不清......
[self.window addSubview:btn];

[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(gotoo) userInfo:nil repeats:YES];//压根没记住......


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值