zoukankan      html  css  js  c++  java
  • UIbutton

    //非原创

    UIbutton作为简单且频繁被使用的控件,其地位在整个app开发中不可小视。在IB中使用button相对来说很简单,很容易上手,但在多视图开发中button通常会被即时生成,并设置其属性和功能,即通过代码生成。如下是我对button的理解。

      //创建圆角button

         UIButton *button = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];      

      //指定button的位置和大小

         button.frame = CGRectMake(10, 10, 75, 75);

      //给button设置标签,用来辨别点击的是哪个button,常用在委托方法中。

         button.tag = 0;

      //定义按钮标题

         [button setTitle:@"Button Title" forState:UIControlStateNormal];

      //定义按钮标题字体格式

         [button.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];

      //给button添加委托方法,即点击触发的事件。

         [button addTarget:selfaction:@selector(touchButton1:)  forControlEvents :UIControl EventTouchUp Inside];

      //给button添加图片 

         [button setImage:[UIImageimageNamed:@"blue_bg(2).png"] forState:UIControlStateNormal];

      //将button加入视图当中

         [view addSubview:button];

    使用技巧:

    button不仅可以用来加载图片还可以加载label来实现特定文本的显示。

    [button addSubview:label];

     
     
     
  • 相关阅读:
    现代软件工程 第一周博客作业
    最后一周总结
    阅读后感
    软件工程作业个人项目——csdn app分析
    第二次结对编程
    软件工程作业二
    软件工程作业一
    ASE 课程最后小结
    阅读后感
    Judy Beta 第五天
  • 原文地址:https://www.cnblogs.com/OIMM/p/4695497.html
Copyright © 2011-2022 走看看