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];

     
     
     
  • 相关阅读:
    123
    搭建https://github.com/vulhub/vulhub靶场_初稿
    【译】 渗透测试实战第三版(红队版)
    sqlmap
    fiddler一些高级用法
    安装django和selenium
    python中os模块
    python通过日志分析加入黑名单
    python简单的购物系统
    python文件操作
  • 原文地址:https://www.cnblogs.com/OIMM/p/4695497.html
Copyright © 2011-2022 走看看