• IOS UI 代码创建UIButton,UITextField,UILabel


        //add a Label

        UILabel *label=[[UILabelalloc]initWithFrame:CGRectMake(100,20, 150, 40)];

        [label setText:@"i am a label "];

        label.font=[UIFontsystemFontOfSize:20];

        label.textAlignment=NSTextAlignmentLeft;

        //文字内容自适应标签宽度

        label.adjustsFontSizeToFitWidth=YES;

        [self.viewaddSubview:label];

       

       

        //add a button

        UIButton *button=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];

        [button setFrame:CGRectMake(100,300, 150, 40)];

        [button setTitle:@"i am a button"forState:UIControlStateNormal];

        //[button addTarget:selfaction:@selector(makeAnotherButton:)forControlEvents:UIControlEventTouchUpInside];

        [self.viewaddSubview:button];

       

       

       

        //add a textField

        UITextField *textField=[[UITextFieldalloc] initWithFrame:CGRectMake(100,150, 150, 40)];

        //[textField setText:@"i am atextField"];

        //只是显示password这个标识

        textField.placeholder=@"password";

        //密码编辑显示圆点PASSWORD

        textField.secureTextEntry=YES;

        //再次对textField编辑时清除内容

        textField.clearsOnBeginEditing=YES;

        //当编辑的时候才有clearButton

        textField.clearButtonMode=UITextFieldViewModeWhileEditing;

        //默认键盘

        textField.keyboardType=UIKeyboardTypeDefault;

       //边框样式 这个我觉得最好看

        textField.borderStyle=UITextBorderStyleRoundedRect;

        textField.textColor=[UIColorblueColor];

        [self.viewaddSubview:textField];

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    虚拟机镜像下载
    The method getTextContent() is undefined for the type Node
    sun.misc.BASE64Encoder找不到jar包的解决方法
    eclipce项目中的js报错解决
    eclipce导入项目导入不进去
    myeclipse新安装好后需要的设置
    mysql软件下载
    Git Bash 命令行方式 提交源码到GitHub
    使用plsql developer 创建用户
    鼠标滑过TAB选项卡切换demo 可拓展
  • 原文地址:https://www.cnblogs.com/yuqingzhude/p/4836552.html
Copyright © 2020-2023  润新知