//

//  ViewController.m

//  VIP

//

//  Created by chuangqu on 15/8/12.

//  Copyright (c) 2015年 theway. All rights reserved.

//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

UIButton *but;

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

UILabel *uilable = [[UILabel alloc] initWithFrame:CGRectMake(100, 50, 50, 30)];//初始化一个UIlable,定义其坐标宽高

uilable.text = @"haha";//标签

[self.view addSubview:uilable];//加入视图

but = [[UIButton alloc] initWithFrame:CGRectMake(200, 50, 50, 30)] ;

//    but.backgroundColor = [UIColor redColor];

//button上面子的颜色

[but setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

//button上显示子名字

[but setTitle:@"set" forState:UIControlStateNormal];

[but addTarget:self action:@selector(but:) forControlEvents:UIControlEventTouchUpInside];//响应按钮

[self.view addSubview:but];

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];

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

[myButton setTitle:@"求最佳哦~" forState:UIControlStateNormal];

[myButton setTitle:@"可以松手~" forState:UIControlStateHighlighted];

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

//    myButton.backgroundColor = [UIColor yellowColor];

myButton.bounds = CGRectMake(0, 0, 200, 100);

myButton.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);

[self.view addSubview:myButton];

UITextField *txt = [[UITextField alloc] initWithFrame:CGRectMake(20, 200, 40, 40)];

[txt.layer setMasksToBounds:YES];

[txt.layer setCornerRadius:8.0]; //设置矩圆角半径

[txt.layer setBorderWidth:1.0];   //边框宽度

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 1, 0, 0, 1 });

[txt.layer setBorderColor:colorref];//边框颜色

[txt setText:@"woqu"];

[self.view addSubview:txt];

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (IBAction)ok:(id)sender {

NSLog(@"Hello,objective-c!");

}

//按钮响事件函数

-(void)myButton:(UIButton *)sender{

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"按钮点击提示" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];

[myAlertView show];

}

-(void)but:(UIButton *)sender{

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"按钮点击提示" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];

[myAlertView show];

}

@end

iOS开发-oc(菜鸟笔记)的更多相关文章

  1. 转:【iOS开发每日小笔记(十一)】iOS8更新留下的“坑” NSAttributedString设置下划线 NSUnderlineStyleAttributeName 属性必须为NSNumber

    http://www.bubuko.com/infodetail-382485.html 标签:des   class   style   代码   html   使用   问题   文件   数据 ...

  2. iOS开发OC基础:Xcode中常见英文总结,OC常见英文错误

    在开发的过程中难免会遇到很多的错误,可是当看到系统给出的英文时,又不知道是什么意思.所以这篇文章总结了Xcode中常见的一些英文单词及词组,可以帮助初学的人快速了解给出的提示.多练习,就肯定能基本掌握 ...

  3. iOS开发——OC篇&OC高级语法

    iOS开发高级语法之分类,拓展,协议,代码块详解 一:分类 什么是分类Category? 分类就是类的补充和扩展部分 补充和扩展的每个部分就是分类 分类本质上是类的一部分 分类的定义 分类也是以代码的 ...

  4. iOS开发-OC语言 (一)oc数据类型

    分享一套以前学习iOS开发时学习整理的资料,后面整套持续更新: oc数据类型 数据类型:基本数据类型.指针数据类型 基本数据类型:数值型.字符型(char).布尔型.空类型(void) 指针数据类型: ...

  5. iOS开发——OC篇&常用关键字的使用与区别

    copy,assign,strong,retain,weak,readonly,readwrite,nonatomic,atomic,unsafe_unretained的使用与区别 最近在学习iOS的 ...

  6. iOS开发——OC篇&消息传递机制(KVO/NOtification/Block/代理/Target-Action)

     iOS开发中消息传递机制(KVO/NOtification/Block/代理/Target-Action)   今晚看到了一篇好的文章,所以就搬过来了,方便自己以后学习 虽然这一期的主题是关于Fou ...

  7. iOS开发——OC篇&纯代码退出键盘

    关于iOS开发中键盘的退出,其实方法有很多中,而且笔者也也学会了不少,包括各种非纯代码界面的退出. 但是最近开始着手项目的时候却闷了,因为太多了,笔者确实知道有很多中方法能实现,而且令我影响最深的就是 ...

  8. iOS开发——OC基础-ARC、BLOCK、协议

    一.ARC ARC 是一种编译器特性!而不是IOS运行时特性,和JAVA中得垃圾回收机制完全不一样ARC是自iOS 5之后增加的新特性,完全消除了手动管理内存的烦琐,编译器会自动在适当的地方插入适当的 ...

  9. iOS开发-OC语言 (四)数组

    知识点 1.NSArray 2.NSMutableArray 1.数组的基本用法: 2.数组的遍历 3.数组排序 ===========   NSArray  不可变数组  ============= ...

  10. iOS开发-OC数据类型

    以下是OC中的实例,Swift部分不适用 iOS中的注释 // 单行注释 // 注释对代码起到解释说明的作用,注释是给程序员看的,不参与程序运行 /*  多行注释   Xcode快捷键   全选 cm ...

随机推荐

  1. linux如何编译安装新内核支持NTFS文件系统?(以redhat7.2x64为例)

    内核,是一个操作系统的核心.它负责管理系统的进程.内存.设备驱动程序.文件和网络系统,决定着系统的性能和稳定性.Linux作为一个自由软件,在广大爱好者的支持下,内核版本不断更新.新的内核修订了旧内核 ...

  2. SQL--视图

  3. VS2012 JSON、XML自动生成对应的类

    在VS编辑下拉框中,选择选择性粘贴(Paste Special)

  4. 【转载】ASP.NET MVC Web API 学习笔记---第一个Web API程序

    1. Web API简单说明 近来很多大型的平台都公开了Web API.比如百度地图 Web API,做过地图相关的人都熟悉.公开服务这种方式可以使它易于与各种各样的设备和客户端平台集成功能,以及通过 ...

  5. RabbitMQ框架学写笔记-20161130

  6. C# ACCESS数据库操作类

    这个是针对ACCESS数据库操作的类,同样也是从SQLHELPER提取而来,分页程序的调用可以参考MSSQL那个类的调用,差不多的,只是提取所有记录的数量的时候有多一个参数,这个需要注意一下! usi ...

  7. .Net 高效开发之不可错过的实用工具(转)

    .Net 高效开发之不可错过的实用工具(转) 本文摘自: http://www.cnblogs.com/powertoolsteam/p/5240908.html#3372237 Visual Stu ...

  8. Winform 导入导出方法

    导出时:引用 using Excel = Microsoft.Office.Interop.Excel; #region 读取excel //打开方法 public DataTable Excelto ...

  9. 禅道 Rest API 开发

    在老的 PHP 系统中使用 PHP 5.3以后的库 所谓老的系统,是指没有使用PHP 5.3以上命名空间(namespace)特性编码的系统. 但是,只要你的系统运行在 PHP 5.3及以上的环境,在 ...

  10. PagerTabStrip及自定义的PagerTab

    如图是效果图      开发中经常会用到上面是一个Tab下面是一个ViewPager(ViewPager再包含几个Fragment),当点击Tab或是滑动ViewPager,Tab及ViewPager ...