objective-c 常用的一些控件。

/***********UIButton***************/
//新建button  UIButtonTypeCustom为隐藏按键  UIButtonTypeRoundedRect 为显示
 UIButton * testbutton = [UIButton buttonWithType:UIButtonTypeCustom];

//设置button的文字显示
 [testbutton setTitle:@"显示"  forState:UIControlStateNormal];

//为按键添加事件
 [testbutton addTarget:self action:@selector(exitselview:) forControlEvents:UIControlEventTouchUpInside];

//如果一次需要设多个button可用for 循环创建.........可给相应的button设一个tag值。方便事件调用的时候用。
testbutton.tag = 0;

//在事件中可与相应的button 关联 判断
if( ((UIButton*)sender).tag ==N)
{
     ......
}
else
{
    .......
}

 

 

 
/*********NSMutableArray **********/
//新建array
NSMutableArray *testArray = [NSMutableArray arrayWithObjects:@"111111",@"22222",@"3333",@"4444",nil];

//取具体的某一个
[testArray objectAtIndex:0]

 

 //计数器
UIScrollView * testview1 = [[UIScrollView alloc]init];
//alloc 后。计数器就为1
NSLog(@"retainCount1:%d",[testview1 retainCount]);
    
//计数器会加1
[testview1 retain];
 NSLog(@"retainCount2:%d",[testview1 retainCount]);
    
//release 后。计数器减1 。当计数器为0时。系统才释放
[testview1 release];
NSLog(@"retainCount3:%d",[testview1 retainCount]);

 

//当动画停止的时候,调用hideAnimationStopped事件
 [UIView setAnimationDidStopSelector:@selector(hideAnimationStopped)];

 

 
//opacity 实现视图的淡入淡出效果
CABasicAnimation *testAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
    //后面的值为0~1 表示当前视图的透明度。
testAnimation.fromValue = [NSNumber numberWithFloat:1];
    //当值为正数时 表示淡入。。当为负数时表示淡出。相当于退出慢慢谈出
testAnimation.toValue =[NSNumber numberWithFloat:-0.5];
testAnimation.duration = 3.0;

 

 

//CABasicAnimation   当动画停止时。触发事件

-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
    [self tooverview];
}

 

qingjoin

转载于:https://www.cnblogs.com/qingjoin/archive/2012/07/18/2597827.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值