ios
codeteenager
让学习成为一种习惯
展开
-
ios中分段控件的使用
NSArray *array=[NSArray arrayWithObjects:@"亚洲",@"欧洲",@"美国",nil]; UISegmentedControl *seg=[[UISegmentedControl alloc]initWithItems:array]; seg.frame=CGRectMake(30, 100, 300, 50); //修改颜色原创 2017-07-30 10:06:23 · 694 阅读 · 0 评论 -
ios中UITextField的使用
UITextField定义UITextField *textField=[[UITextField alloc] initWithFrame:CGRectMake(20, 20, 100, 50)];UITextField属性背景颜色:extField.backgroundColor=[UIColor redColor];输入框提示:textField.placeholder=@”友情提示”;原创 2017-07-25 11:40:07 · 251 阅读 · 0 评论 -
ios中提示框的使用
旧版提示框UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"友情提示" message:@"是否是成年人" delegate:self cancelButtonTitle:@"不满足" otherButtonTitles:@"满足", nil]; alt.delegate=self; [alt show];UIAlertVie原创 2017-07-25 13:57:29 · 4663 阅读 · 0 评论 -
ios中定时器
ios中定时器的定义: [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(<#selector#>) userInfo:nil repeats:NO];原创 2017-07-25 14:52:43 · 182 阅读 · 0 评论 -
ios中UIImageView的使用
UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 50, 50)];imageview.backgroundColor=[UIColor blueColor];[self.view addSubview:imageview];UIImage *image=[UIImage imageNamed原创 2017-07-25 15:19:05 · 168 阅读 · 0 评论 -
ios中跳转界面
话不多说直接上代码SecondViewController *second=[SecondViewController alloc];second.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;[self presentViewController:second animated:YES completion:^{}];首先原创 2017-07-25 16:38:04 · 255 阅读 · 0 评论 -
ios中自定义视图
自定义View步骤新建一个类继承自UIView分析新视图由哪些旧视图构成,并且把它声明为属性重写初始化方法,在方法里完成布局将私有属性放在延展中,然后添加公有方法为其设置属性简单的案例如下:MyView.h@interface MyView : UIView-(void)setLabelText:(NSString*) content;@endMyView.m@interfac原创 2017-07-25 17:17:23 · 283 阅读 · 0 评论 -
ios中屏幕触摸和摇晃的方法
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ //触摸开始}-(void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ //取消触摸}-(void)touchesEnded原创 2017-07-25 23:42:18 · 857 阅读 · 0 评论 -
ios学习笔记一之Object-c基础
源代码文件扩展名头文件.h 实现文件.m类的定义@ interface SimpleClass: NSObject ..代码片段 @end类的属性@property (readonly)属性类型 属性名(基础类型不加,指针类型即对象类型需加*,readonly是代表只能获取值但是不能写入值)类的方法减号方法(普通方法又称为对象方法) 加号方法(类方法又称为静态方法)原创 2017-07-12 17:54:19 · 281 阅读 · 0 评论 -
ios六大手势的创建使用
点击手势 //创建点击手势 UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapMe)]; //控制点击此时 tap.numberOfTapsRequired=3; //创建图片控件 UIImageView *原创 2017-07-27 17:25:16 · 375 阅读 · 0 评论 -
ios中NSURLConnection的使用
NSURLConnection的使用 //定义url NSURL *url=[NSURL URLWithString:@"http://www.baidu.com"]; //定义请求 NSURLRequest *request=[NSURLRequest requestWithURL:url]; //发送异步请求 [NSURLConnection sen原创 2017-08-02 16:01:39 · 272 阅读 · 0 评论 -
ios中pod相关命令
pod安装添加源gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/查看源gem sources -l安装cocoapodsgem install cocopods设置pod setup创建默认的Podfilepod init第一次使用安装框架pod install安装框架,不更新本地索引,速度快p原创 2017-08-01 23:44:40 · 311 阅读 · 0 评论 -
ios中引导页的制作
//创建可滚动视图 UIScrollView *scroll=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 375, 667)]; //设置视图中内容的大小 scroll.contentSize=CGSizeMake(375*4, 667); //设置是否分页 scroll.pagingEnabled原创 2017-07-30 23:01:47 · 195 阅读 · 0 评论 -
ios中导航控制器的使用
在window中设置导航控制器FirstViewController *first=[FirstViewController alloc];//创建导航控制器UINavigationController *controller=[[UINavigationController alloc]initWithRootViewController:first];//将导航控制器作为window的根视原创 2017-07-31 00:12:48 · 1222 阅读 · 0 评论 -
ios中淘宝底部导航栏的制作
//创建第一个页面控制器 FirstViewController *first=[[FirstViewController alloc] init]; //创建第一个页面导航控制器 UINavigationController *firstNav=[[UINavigationController alloc]initWithRootViewController:first];原创 2017-08-01 13:09:28 · 1390 阅读 · 0 评论 -
ios中自定义cell即列表的item
继承UITableViewCell,并定义属性。@interface MyTableViewCell : UITableViewCell//定义需要的属性控件@property(nonatomic,strong)UIImageView *icon;@property(nonatomic,strong)UILabel *name;@property(nonatomic,strong)UILab原创 2017-08-01 16:13:19 · 482 阅读 · 0 评论 -
ios中列表UITableView的使用
首先在代码中实现两个代理UITableViewDelegate,UITableViewDataSource。@interface RootViewController ()<UITableViewDelegate,UITableViewDataSource>@end然后创建UITableView类,并设置代理。 UITableView *table=[[UITableView alloc]in原创 2017-08-01 14:12:25 · 184 阅读 · 0 评论 -
ios中通过代码来创建第一个页面
在ios中当你创建一个Empty工程之后,默认不会创建xib或者storyboard界面,这时候需要你通过代码来创建页面。一般来说,ios的窗口是UIWindow,然后在window中添加UIViewController作为页面。首先,你需要在AppDelegate.m文件中实例化window,然后再添加Controller作为第一个页面,代码如下。self.window=[[UIWindow al原创 2017-07-24 14:46:48 · 1397 阅读 · 0 评论 -
ios中UIView的常用属性
UIView的定义UIView *view=[[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];UIView的常用属性背景颜色: view.backgroundColor=[UIColor redColor];透明度:view.alpha=0.5;是否隐藏:view.hidden=YES;中心点:view.center原创 2017-07-24 15:58:02 · 270 阅读 · 0 评论 -
ios中UILabel的使用
UILabel定义UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 50)];UILabel的属性背景色:label.backgroundColor=[UIColor redColor];label文字内容:label.text=@”标签文字”;label中文字对齐方式:label.textAlign原创 2017-07-24 15:58:28 · 166 阅读 · 0 评论 -
ios中UIButton的使用
UIButton的定义UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];UIButton的属性指定位置和大小:button.frame=CGRectMake(10, 100, 160, 40);设置按钮上的文字:[button setTitle:@”文字” forState:UIControlStateNormal];设原创 2017-07-24 17:08:43 · 253 阅读 · 0 评论 -
ios中多线程的使用
ios多线程的四种方式pthread 不怎么使用NSThreadGCDNSOperation原创 2017-08-04 17:44:42 · 199 阅读 · 0 评论