iOS 一些UI控件的属性

   UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    //能够定义的button类型有以下6种

    /*typedef enum{

     UIButtonTypeCustom = 0;   自定义风格

     UIButtonTypeRoundedRect,  圆角矩形

     UIButtonTypeDetailDisclosure  蓝色小箭头按钮,主要做详细说明用

     UIButtonTypeInfoLight    // 亮色感叹号

     UIButtonTypeInfoDark    暗色感叹号

     UIButtonTypeContactAdd   十字加号按钮

     }UIButtonType;

     给定button在view上的位置

    button.frame = CGRectMake(20, 20, 280, 40);

     

    */

    // button背景色

   // button.backgroundColor = [UIColor clearColor];

    // 设置button填充图片

    //[button setImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal];

    /*forState:这个参数的作用是定义按钮的文字或图片在何种状态下才会显现*/

    //以下是几种状态

    // enum{

//    UIControlStateNormal = 0;  常规状态显现

//    UIControlStateHighlighted = 1<<0;   高亮状态显现

//    UIControlStateDisabled = 1<<1;  禁用的状态才会显现

//    UIControlStateSelected = 1<<2;  选中状态

//    UIControlStateApplication = 0x00FF0000  为应用程序标志时

//    UIControlStateReserved = 0xFF000000  为内部框架预留,可以不管他

    /* 默认情况下,当按钮高亮的情况下,图像的颜色会被画深一点,如果这下面的这个属性设置为no,那么可以去掉这个功能 */

    //button.adjustsImageWhenHighlighted = NO;

    /* 跟上面的情况一样,默认情况下,当按钮禁用的时候,图像会被画得深一点,设置NO可以取消设置*/

   // button.adjustsImageWhenDisabled = NO;

    /*下面得这个属性设置为YES的状态下,按钮按下会发光*/

    //button.showsTouchWhenHighlighted = YES;

    // 按钮点击事件

    // butClick: 这个方法

    // addTarget:self 的意思是说,这个方法在本类中也可以传入其他的指针

   // [button addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];

    // 显示控件

    //[self.view addSubview:button];

    // 注意:

//    [button addTarget:self action:@selector(alarmTimeDo:) forControlEvents:UIControlEventTouchUpInside];

//addTarget:self 是链接到self,一般都这样设置

//action:@selector(alarmTimeDo:) 时间处理函数

//forControlEvents:UIControlEventTouchUpInside  控件事件处理的消息

    

    // 取消按钮已经添加的所有的事件:(这个比较重要,若添加了两个事件 两个事件都会被触发)

    //[button removeTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];

    // 何时释放  release UIButton?

    // 是否在dealloc 中对UIButton 对象进行 release操作,取决于UIButton初始化的方式 如果使用

//    [UIButtonbuttonWithType:UIButtonTypeCustom]; 这种方式,是不需要进行release操作的,因为这种方式是自动释放的,如果使用[[UIBUtton alloc]init];的方式,则需要主动进行release释放操作。

    // iOS UIBtton 事件:

//    UIControlEventTouchDown  单击触摸按下事件:用户触屏幕,或者又有新手指落下的时候。

//    UIControlEventTouchDownRepeat  多点触摸按下事件,点数技术大于1,用户按下第二,三,或第四跟手指的时候

//    UIControlEventTouchDragInside  当一次触摸在控件窗口内拖动时;

//    UIControlEventTouchDragOutside  当一次触摸在控件窗口之外拖动时

//    UIControlEventTouchDragInside  当一次触摸在控件窗口之内拖动时

//    UIControlEventTouchDragEnter  当一次触摸从控件窗口之外拖动到内部时

//    UIControlEventTouchDragExit  当一次触摸从控件窗口内部拖动到外部时。

//    UIControlEventTouchUpInside  所以在控件之内触摸抬起事件

//    UIControlEventTouchUpOutside  所有在控件之外触摸抬起事件(点触必须开始与控件内部)

//    UIControlEventTouchCancel  所有触摸取消事件,即一次触摸因为放上了太多手指而被取消,或者被上锁或者电话呼叫打断

//    UIControleventEditingtouchchanged  当控件的值发生改变时,发送通知,用于滑块,分段控制

//    UIControlEventEditingDidBegin  当文本控件中开始编辑时发送通知。

//    UIControlEventEditingDidEnd   当文本控件中编辑结束时发送通知

//    UIControlEventEditingDidEndOnExit  当文本控件内通过按下回车键(或等价行为)结束编辑时

//    UIControlEventAllEditingEvents   通知所有关于文本编辑的事件

//    UIControlEventAllTouchEvents    通知所有触摸事件

//    UIControlEventAllEvents   通知所有事件

 

posted @ 2015-05-06 15:52  certify  阅读(138)  评论(0编辑  收藏  举报