博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[非凡程序员]UIKit 手写控件
阅读量:7305 次
发布时间:2019-06-30

本文共 1396 字,大约阅读时间需要 4 分钟。

hot3.png

//

//  ViewController.m

//  手写控件

//

//  Created by 非凡程序员 on 15/11/11.

//  Copyright (c) 2015 Querida. All rights reserved.

//

#import "ViewController.h"

ViewController ()

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    UILabel *lable=[[UILabel alloc]initWithFrame:CGRectMake(20, 20, 300, 200)];

    //标签文字内容

    lable.text=@"CuiXiaoYu";

    //标签文字字体格式和字体大小

    lable.font=[UIFont fontWithName:@"Zapfino" size:30];

    //设置标签字体颜色

    lable.textColor=[UIColor yellowColor];

    //设置圆角边框的角度

    lable.layer.cornerRadius=20;

    //设置背景颜色

    lable.backgroundColor=[UIColor redColor];

    //设置标签边框的颜色

    lable.layer.borderColor=[UIColor blackColor].CGColor;

    //设置标签边框的宽度

    lable.layer.borderWidth=20;

    //标签文字居中

    lable.textAlignment=NSTextAlignmentCenter;

    //将控件添加到当前图层上

    [self.view addSubview:lable];

    

    // --------关于UITextFeild--------

    UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(20, 400, 100, 80)];

    [button setTitle:@"按钮" forState:UIControlStateNormal];

    [button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];

    button.backgroundColor=[UIColor orangeColor];

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

    [self.view addSubview:button];

    

}

-(void)diJi:(UIButton *)b{

    NSLog(@"点了~");

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

@end

转载于:https://my.oschina.net/u/2499773/blog/529012

你可能感兴趣的文章
微软百名员工签名力挺 996.ICU
查看>>
1042. Shuffling Machine (20)
查看>>
Android随笔——搞定流动布局(FlexboxLayout)
查看>>
初学Python——第一节课
查看>>
Angular 的 ngOnInit 和 Constructor 的区别!
查看>>
Docker系列教程16-network命令
查看>>
JPA 注解学习
查看>>
数据采集新形态-全球加速
查看>>
02.系统配置与性能评价
查看>>
Nginx架构--nginx系列之二
查看>>
弹性计算双周刊 第12期
查看>>
前端神器-神级代码编辑软件Sublime Text下载、使用教程、插件推荐说明、全套快捷键...
查看>>
【Java入门提高篇】Day5 Java中的回调(二)
查看>>
Ali-HBase的SQL实践与改进
查看>>
修改oracle配置参数
查看>>
struts2-01:作用域传值
查看>>
支付宝付款页面调整屏幕亮度
查看>>
基于Spring的RPC通讯模型.
查看>>
java基础学习_面向对象(下)03_day10总结
查看>>
经济学和营销及推销的关系
查看>>