//

//  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. Android Studio快捷键每日一练(6)

    原文地址:http://www.developerphil.com/android-studio-tips-of-the-day-roundup-6/ 51.重构代码 苹果:Ctrl+T    Win ...

  2. C#中方法的声明

    C#中方法的声明(四要素) 访问修饰符 :public,private(方法的默认访问修饰符) 返回值类型:void 和 非void 方法名称    : 规范是方法名称取动词,每个单词的首字母大写. ...

  3. 常用的 SQL语句------CRUD

    复习之前课本上的sql语句,以前上课的时候都是老师在上面讲,我们在下面玩,根本没有把这个放在心上,等到考试的时候临时学习突击下,就可以顺利过60了,但是现在不行了,自己要重新的学习sql,应该把里面最 ...

  4. 30天C#基础巩固----程序集,反射

    一:认识程序集       只要是使用VS就会和程序集打交道,我们通过编辑和生产可执行程序就会自动生成程序集.那么什么事程序集呢,.net中的dll与exe文件的都是程序集(Assembly).    ...

  5. Lua使用心得(1)

    这几天研究了一下lua,主要关注的是lua和vc之间的整合,把代码都写好放在VC宿主程序里,然后在lua里调用宿主程序的这些代码(或者叫接口.组件,随便你怎么叫),希望能用脚本来控制主程序的行为.这实 ...

  6. 基于TCP和多线程实现无线鼠标键盘-GestureDetector

    为了实现无线鼠标,需要识别出用户在手机屏幕上的滑动动作,这就需要用到GestureDetector类. 首先是activity_main.xml: <LinearLayout xmlns:and ...

  7. X3D中Profile如何翻译

    问题在哪 在计算机术语中,Profile其实是很难用中文对应的词汇来翻译的一个单词. 在X3D国际标准中,就出现了Profile.它把软件产品对X3D的功能实现范围和相应支持程度做了预先的约定,分为C ...

  8. Titanium Studio下载地址

    http://titanium-studio.s3.amazonaws.com/latest/titanium.studio.linux.gtk.x86_64.zip http://titanium- ...

  9. C#生成随机验证码

    使用YZMHelper帮助类即可 using System; using System.Web; using System.Drawing; using System.Security.Cryptog ...

  10. android 查找某个特定文件后缀名

    private void queryFiles(){ String[] projection = new String[] { MediaStore.Files.FileColumns._ID, Me ...