当你定义了一系列的变量时,需要写很多的getter和setter方法,而且它们的形式都是差不多的,,所以Xcode提供了@property
和@synthesize属性,@property用在 .h 头文件中用作声明,@synthesize用在.m 文件中用于实现。如下,新建一个基于“Command Line Tool”的项目,名为“property”,再新建一个Student类,传统的写法是:Student.h[cpp]view plaincopy// // Student.h // property // // Created by Rio.King on 13-8-2...
iOS开发UI篇—transframe属性(形变)1. transform属性在OC中,通过transform属性可以修改对象的平移、缩放比例和旋转角度常用的创建transform结构体方法分两大类(1) 创建“基于控件初始位置”的形变CGAffineTransformMakeTranslation(平移)CGAffineTransformMakeScale(缩放)CGAffineTransformMakeRotation(旋转) (2) 创建“基于transform参数”的形变CGAffineTransformTranslateCGAffineTransformScaleCGAffineTransfor...
(1)UITextView和UITextField的区别可以(简单)理解为,前者是一块区域可以写很多东西有换行滚动条神马的,后者只有一行文本,类似于html里面的textarea和text。(2)在本例中,我们利用一个UITextField和一个UIButton不断把UITextField里面的内容加到UITextView的最后一行。这里面用到给按钮增加 一个事件,并在事件里面把UITextField.text加到UITextView.text的后面。(3)在本例中为了用户体验,可以设置每次增减内容后,光标...
-(id)initWithDic:(NSDictionary *)dic
{if (self = [super init]) {[self setValuesForKeysWithDictionary:dic];}return self;
}-(void)setValue:(id)value forUndefinedKey:(NSString *)key{if ([key isEqualToString:@"new_app_picpath"]) {_mynew_app_picpath = value;}
}原文:http://www.cnblogs.com/WJJ-Dream/p/5809191.html
文本属性Attributes1.NSKernAttributeName: @10 调整字句 kerning 字句调整2.NSFontAttributeName : [UIFont systemFontOfSize:_fontSize] 设置字体3.NSForegroundColorAttributeName :[UIColor redColor] 设置文字颜色4.NSParagraphStyleAttributeName : paragraph 设置段落样式5.NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];paragraph.alignment = NSTextAlignmentCenter;6.NSBackgroundColor...
vue-resource更换为axiosnpm install axios/*main.js*/import axios from ‘axios‘Vue.prototype.$ajax = axios/*components*/import axios from ‘axios‘export default { created () { axios.get(‘./static/data.json‘).then(res => { }) }}获取DOM<div class="tab" ref="domList"></div><script>created () { this.$nextTick(() => { console.log(this.$refs.domList) })}</script>原文:http://www.cnb...
在次之前,补充个内容。UIDevice是无法获得具体的设备型号的。要获得设备型号,比如(iphone 4s, iphone5)这样的,要通过这样的办法。1.引入头文件。#include <sys/types.h>#include <sys/sysctl.h>2.获取型号 //手机型号。
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = (char*)malloc(size);
sysctlbyname("hw.machine", machin...
contentSize 属于CGSize类型,CGSizeMake(width,height),宽度决定了UIScrollView滚动的水平距离,height决定了UIScrollView滚动的纵向距离,contenSize属性如果不设置值那么不能滚动视图 //设置一个UIScrollView UIScrollView *sv = [[UIScrollView alloc] initWithFrame:self.view.bounds]; sv.backgroundColor = [UIColor cyanColor]; [self.view addSubview:sv]; //添加一个视图 UIImage *image = [UIIma...
1.NSKernAttributeName:@10 调整字句 kerning 字句调整 2.NSFontAttributeName :[UIFont systemFontOfSize:_fontSize] 设置字体 3.NSForegroundColorAttributeName:[UIColor redColor] 设置文字颜色 4.NSParagraphStyleAttributeName :paragraph 设置段落样式NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];paragraph.alignment = NSTextAlignmentCenter; 6.NSBackgroundColorAttributeName:[UICol...
直接上代码,里面有各种属性的用法注释,至于每个属性有多个可以设置的值,每个值的效果如何,可以通过查看这个函数参数的枚举量,并逐一测试。 1//制作登陆界面 2#import"ViewController.h" 3 4@interface ViewController (){5 6//定义全局变量(控件) 7 UITextField *username;8 UITextField *password;9 UIButton *resignbutton;10 UIButton *loginbutton;11int i;12 NSMutableArray *imagearray;1...
//1.添加按钮UIButton *nameView=[UIButton buttonWithType:UIButtonTypeCustom];//nameView.backgroundColor=[UIColor redColor];[nameView setBackgroundImage:[UIImage imageNamed:@"buddy_header_bg"] forState:UIControlStateNormal];[nameView setBackgroundImage:[UIImage imageNamed:@"buddy_header_bg_highlighted"] forState:UIControlStateHighlighted];//设置按钮内部的左边箭头图片[nameView setImage:[UIImage image...
在IOS开发的过程中,UILabel是很常用的一个控件,同时也是大量使用的一个控件。创建一个UILabel一般需要五六句代码,如果我们需要创建几十个UILabel,就意味着我们要写五六十句代码,其实很多代码是重复的,我们可以把类似的代码写到一个公共的方法中,以提高工作效率和降低代码重复。官方提供UILabel的一些属性有很大的局限性,有些在项目中开发中需要用到的一些拓展性的属性,根据个人经验,也顺便一起总结在这里。 一、创建UILa...
objective-c中,有类别可以在不修改源码的基础上增加方法;近排在看别人的开源代码时,发现还可以动态增加属性。而且是在运行时,太牛B了。使用运行时库,必须要先引入 objc/runtime.h可以使用的函数如下:OBJC_EXPORT void objc_setAssociatedObject(id object, const void *key, id value, objc_AssociationPolicy policy)这个函数OBJC_EXPORT id objc_getAssociatedObject(id object, const void *key)__OSX_AVAILABLE_STARTING(...
1.tableView的刷新1> 数据刷新的总体步骤* 修改模型数据* 刷新表格(刷新界面) 2> 刷新表格(刷新界面)的方法* 全局刷新(每一行都会重新刷新)- (void)reloadData; * 局部刷新(使用前提: 刷新前后, 模型数据的个数不变)- (void)reloadRows:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation; * 局部删除(使用前提: 模型数据减少的个数 == indexPaths的长度)- (void)deleteRowsAtIndexPaths:(NSArray *)inde...
你要知道的runtime都在这里转载请注明出处 http://blog.csdn.net/u014205968/article/details/67639303本文主要讲解runtime相关知识,从原理到实践,由于包含内容过多分为以下五篇文章详细讲解,可自行选择需要了解的方向:从runtime开始: 理解面向对象的类到面向过程的结构体从runtime开始: 深入理解OC消息转发机制从runtime开始: 理解OC的属性property从runtime开始: 实践Category添加属性与黑魔法method swizzling从runtime开始:...