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 ...
随机推荐
- 用Eclipse新建一个web项目没有自动生成web.xml
我们首先打开Eclipse,如下: 我们可以看到在"WEB-INF"文件夹下没有web.xml文件. 这是是什么原因呢,我们来看看,我们首先来新建一个web工程,如下: ...
- 最简单的pagging插件
<html> <head> <title>jQuery Easy-Paging Test</title> </head> <body& ...
- ORLEANS REMOTE DEPLOYMENT
Orleans Remote Deployment Table of Contents Overview: 1 Prerequisites. 2 Deployment Steps. 2 Orleans ...
- android 开发环境搭建
http://www.cnblogs.com/bjzhanghao/archive/2012/11/14/2769409.html http://jingyan.baidu.com/article/7 ...
- Java--Semaphore控制并发线程数量
package com; import java.util.concurrent.Semaphore; /** * Created by yangyu on 16/11/28. */ /** * Se ...
- extern的用法
extern作为外部函数声明的用法: 1. 可以扩展函数的应用范围: 107.h #ifndef _107H_ #def _107H_ extern void func(); #endif 107.c ...
- Linux下如何查看哪个进程占用内存多?
1.top top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器 可以直接使用top命令后,查看%MEM的内容.可以选择按进程查看或者 ...
- Java清除:收尾和垃圾收集
垃圾收收集器(GC)只知道释放由new关键字分配的内存,所以不知道如何释放对象的"特殊"内存.为了解决这个问题,Java提供了一个名为:finalize()的方法,可为我们的类定义 ...
- 「Unity」与iOS、Android平台的整合:2、导出的Android-Eclipse工程
谢谢关注~由于博客园的写字有些蛋疼,已经搬迁到简书了 这是本篇文章的最新连接
- WebSocket 学习笔记--IE,IOS,Android等设备的兼容性问题与代码实现
一.背景 公司最近准备将一套产品放到Andriod和IOS上面去,为了统一应用的开发方式,决定用各平台APP嵌套一个HTML5浏览器来实现,其中数据通信,准备使用WebSocket的方式.于是,我开始 ...