摘要: UIActionSheet是在IOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件。为了快速完成这例子,我们打开Xcode 4.3.2, 先建立一个single view application。然后再xib文件添加一个button,用来弹出sheet view。1、首先在.h文件中实现协议,加代码的地方在@interface那行的最后添加,协议相当于java里的接口,实现协议里的方法。@interface sheetviewViewController : UIViewController@end2、添加button,命名button为showSheetView.3、为button建立 阅读全文
posted @ 2014-02-15 11:27 yulang 阅读(240) 评论(0) 推荐(0)
摘要: 系统自带的UISwitch是这样的:既不能写字,也不能改颜色,于是在网上找到了这么一个自定义的Switch按钮,具体出处找不见了。记录一下,怕以后找不见了。先看下效果图:按钮的样式很多,可以文字,可以写多行,文字大小和颜色都可以设置。看下它的源码:[cpp]view plaincopy#import@interfaceHMCustomSwitch:UISlider{BOOLon;UIColor*tintColor;UIView*clippingView;UILabel*rightLabel;UILabel*leftLabel;//privatememberBOOLm_touchedSelf;} 阅读全文
posted @ 2014-02-15 11:25 yulang 阅读(1699) 评论(0) 推荐(0)
摘要: 举例:UIAlertView *alertView= [[UIAlertView alloc]initWithTitle:@"Default Alert View"message:@"Defalut"delegate:selfcancelButtonTitle:@"Cancel"otherButtonTitles:@"OK",nil];标准的双按钮,cancel那个buttonIndex 为0, ok button 的buttonIndex为1UIAlertView *alertView= [[UIAlertVie 阅读全文
posted @ 2014-02-15 11:20 yulang 阅读(256) 评论(0) 推荐(0)
摘要: 初始化UISegmentedControlNSArray *arr = [[NSArray alloc]initWithObjects:@"轻拍",@"长按",@"清扫",@"旋转",@"捏合",@"拖拽", nil];//先创建一个数组用于设置标题UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:arr];//在没有设置[segment setApportionsSegmentWid 阅读全文
posted @ 2014-02-15 11:12 yulang 阅读(423) 评论(0) 推荐(0)
摘要: 初始化一个SliderUISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(0, 400,320 , 20)];滑块是一个标准的UIControl。我们可以通过代码创建,如同开关(UISwitch)的宽与高都会被忽略一样滑块的高也会被忽略(但是宽度不会):二、设定范围与默认值创建完毕的同时我们要设置好滑块的范围,如果你没有设置,那么会使用默认的 0.0 到 1.0 之间的值。UISlider提供了两个属性来设置范围:mininumValue 和 maxinumValue:源码打印?mySlider.mininumValue=0 阅读全文
posted @ 2014-02-15 11:10 yulang 阅读(558) 评论(0) 推荐(0)
摘要: //初始化textfield并设置位置及大小 UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];//设置边框样式,只有设置了才会显示边框样式 text.borderStyle = UITextBorderStyleRoundedRect; typedef enum { UITextBorderStyleNone, UITextBorderStyleLine, UITextBorderStyleBezel, UITextBorderStyleRoundedRect } ... 阅读全文
posted @ 2014-02-15 11:08 yulang 阅读(186) 评论(0) 推荐(0)
摘要: UIImageView,顾名思义,是用来放置图片的。使用Interface Builder设计界面时,当然可以直接将控件拖进去并设置相关属性,这就不说了,这里讲的是用代码。1、创建一个UIImageView:创建一个UIImageView对象有五种方法:UIImageView *imageView1 = [[UIImageView alloc] init]; UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:(CGRect)]; UIImageView *imageView3 = [[UIImageView alloc] 阅读全文
posted @ 2014-02-15 11:04 yulang 阅读(246) 评论(0) 推荐(0)
摘要: 第一、UIButton的定义 UIButton*button=[[UIButton buttonWithType:(UIButtonType);能够定义的button类型有以下6种,typedef enum {UIButtonTypeCustom = 0, 自定义风格UIButtonTypeRoundedRect, 圆角矩形UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用UIButtonTypeInfoLight, 亮色感叹号UIButtonTypeInfoDark, 暗色感叹号UIButtonTypeContactAdd, 十字加号按钮} UIBu 阅读全文
posted @ 2014-02-15 11:01 yulang 阅读(375) 评论(0) 推荐(0)
摘要: 详细使用:UILabel *label = [[UILabelalloc] initWithFrame:CGRectMake(0, 0, 75, 40)]; //声明UIlbel并指定其位置和长宽label.backgroundColor = [UIColorclearColor]; //设置label的背景色,这里设置为透明色。label.font = [UIFont fontWithName:@"Helvetica-Bold" size:13]; //设置label的字体和字体大小。label.transform = CGAffineTransformMakeRotat 阅读全文
posted @ 2014-02-15 10:59 yulang 阅读(264) 评论(0) 推荐(0)
摘要: 这个程序的主要界面就是一个TabBarController。总共三个标签,第一个是所有的可点的菜,第二个是已点的菜,第三个是可以留言或者查看所有留言。下面是第一个页面:右上角的i按钮是添加新菜,每个cell中的order就是点餐咯,可以重复按多次。首先说下这个列表的数据是存放在coredata中的,这个项目的coredata有两个实体,一个是dishes保存每一道菜的名字,id,价格,描述,菜系等。还有一个实体是type保存菜系。这个项目用coredata的方式,正好是我想学的。就是在新建项目的时候勾选use coredata,那么在appdelegate中就会出现与coredata响应的代码 阅读全文
posted @ 2014-02-15 10:51 yulang 阅读(553) 评论(0) 推荐(0)