objectivec 常用的一些控件。

/***********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/p/2597827.html