iOS开发-oc(菜鸟笔记)
//
// 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(菜鸟笔记)的更多相关文章
- 转:【iOS开发每日小笔记(十一)】iOS8更新留下的“坑” NSAttributedString设置下划线 NSUnderlineStyleAttributeName 属性必须为NSNumber
http://www.bubuko.com/infodetail-382485.html 标签:des class style 代码 html 使用 问题 文件 数据 ...
- iOS开发OC基础:Xcode中常见英文总结,OC常见英文错误
在开发的过程中难免会遇到很多的错误,可是当看到系统给出的英文时,又不知道是什么意思.所以这篇文章总结了Xcode中常见的一些英文单词及词组,可以帮助初学的人快速了解给出的提示.多练习,就肯定能基本掌握 ...
- iOS开发——OC篇&OC高级语法
iOS开发高级语法之分类,拓展,协议,代码块详解 一:分类 什么是分类Category? 分类就是类的补充和扩展部分 补充和扩展的每个部分就是分类 分类本质上是类的一部分 分类的定义 分类也是以代码的 ...
- iOS开发-OC语言 (一)oc数据类型
分享一套以前学习iOS开发时学习整理的资料,后面整套持续更新: oc数据类型 数据类型:基本数据类型.指针数据类型 基本数据类型:数值型.字符型(char).布尔型.空类型(void) 指针数据类型: ...
- iOS开发——OC篇&常用关键字的使用与区别
copy,assign,strong,retain,weak,readonly,readwrite,nonatomic,atomic,unsafe_unretained的使用与区别 最近在学习iOS的 ...
- iOS开发——OC篇&消息传递机制(KVO/NOtification/Block/代理/Target-Action)
iOS开发中消息传递机制(KVO/NOtification/Block/代理/Target-Action) 今晚看到了一篇好的文章,所以就搬过来了,方便自己以后学习 虽然这一期的主题是关于Fou ...
- iOS开发——OC篇&纯代码退出键盘
关于iOS开发中键盘的退出,其实方法有很多中,而且笔者也也学会了不少,包括各种非纯代码界面的退出. 但是最近开始着手项目的时候却闷了,因为太多了,笔者确实知道有很多中方法能实现,而且令我影响最深的就是 ...
- iOS开发——OC基础-ARC、BLOCK、协议
一.ARC ARC 是一种编译器特性!而不是IOS运行时特性,和JAVA中得垃圾回收机制完全不一样ARC是自iOS 5之后增加的新特性,完全消除了手动管理内存的烦琐,编译器会自动在适当的地方插入适当的 ...
- iOS开发-OC语言 (四)数组
知识点 1.NSArray 2.NSMutableArray 1.数组的基本用法: 2.数组的遍历 3.数组排序 =========== NSArray 不可变数组 ============= ...
- iOS开发-OC数据类型
以下是OC中的实例,Swift部分不适用 iOS中的注释 // 单行注释 // 注释对代码起到解释说明的作用,注释是给程序员看的,不参与程序运行 /* 多行注释 Xcode快捷键 全选 cm ...
随机推荐
- Elasticsearch 教程--入门
1.1 初识 Elasticsearch 是一个建立在全文搜索引擎 Apache Lucene(TM) 基础上的搜索引擎,可以说 Lucene 是当今最先进,最高效的全功能开源搜索引擎框架. 但是 L ...
- C#去掉HTML标记
该方法亲测可行,下面直接粘贴代码. public string RemoveHTMLTags(string htmlStream) { if (htmlStream == null) { throw ...
- 编写高性能SQL
前言:系统优化中一个很重要的方面就是SQL语句的优化.对于海量数据,劣质SQL语句和优质SQL语句之间的速度差别可达到上百倍,可见对于一个系统不是简单的能实现其功能就可以了,而是要写出高质量的SQL语 ...
- Delegate
public delegate void EventHandler(object sender, EventArgs e); pulic EventHandler HandleMapMessage; ...
- Mysql调试存储过程最简单的方法
以前同事告诉我用临时表插入变量数据来查看,但是这种方法过于麻烦,而且Mysql没有比较好的调试存储过程的工具.今天google了下发现可以用select + 变量名的方法来调试...真是让我汗颜啊. ...
- 线程Thread的基础知识学习
一.线程的基本概念 1.线程是一个程序内部的顺序控制流. 2.Java的线程是通过java.lang.Thread类来实现的. 3.VM启动时会有一个由主方法{public static void m ...
- [moka同学笔记]Yii2 自定义class、自定义全局函数(摘录)
1.在app\components下新建MyComponent.PHP namespace app\components; use Yii; use yii\base\Component; use y ...
- InfluxDB学习之InfluxDB的基本概念
InfluxDB与传统数据库在概念上有许多的不同,本文就给大家介绍下InfluxDB中的一些基本概念,更多InfluxDB详细教程请看:InfluxDB系列学习教程目录 InfluxDB技术交流群:5 ...
- viewport ——视区概念,为 自适应网页设计
什么是Viewport 手机浏览器是把页面放在一个虚拟的“窗口”(viewport)中,通常这个虚拟的“窗口”(viewport)比屏幕宽,这样就不用把每个网页挤到很小的窗口中(这样会破坏没有针对手机 ...
- HTML5 Canvas 高仿逼真 3D 布料图案效果
HTML5 规范引进了很多新特性,其中最令人期待的之一就是 Canvas 元素,HTML5 Canvas 提供了通过 JavaScript 绘制图形的方法,非常强大.下面给大家分享一个 HTML5 C ...