文件名称:自定义开关按钮(ios)
文件大小:86KB
文件格式:ZIP
更新时间:2015-06-20 15:34:02
自定义的开关 segmentcontrol
可以设置开关的颜色,修改字符串等。例如,用图片代替:UIImage *normal_left = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_normal" ofType:@"png"]]; UIImage *normal_right = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"right_normal" ofType:@"png"]]; NSMutableArray *unselectImages = [[NSMutableArray alloc]initWithObjects:normal_left, normal_right, nil]; [normal_left release]; [normal_right release]; UIImage *select_left = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_press" ofType:@"png"]]; UIImage *select_right = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"right_press" ofType:@"png"]]; NSMutableArray *selectImages = [[NSMutableArray alloc]initWithObjects: select_left, select_right, nil]; [select_left release]; [select_right release]; CQSegmentControl *_segmentedControl= [[CQSegmentControl alloc] initWithItemsAndStype:titleItems stype:TitleAndImageSegmented]; for (UIView *subView in _segmentedControl.subviews) { [subView removeFromSuperview]; } _segmentedControl.normalImageItems = unselectImages; [unselectImages release]; _segmentedControl.highlightImageItems = selectImages;
【文件预览】:
CustomSegmented(自定义开关按钮)
----main.m(367B)
----left_press.png(4KB)
----right_normal.png(3KB)
----CustomSegmented_Prefix.pch(199B)
----CustomSegmentedViewController.xib(7KB)
----right_press.png(4KB)
----CustomSegmented.xcodeproj()
--------qiancheng.mode1v3(40KB)
--------project.xcworkspace()
--------qiancheng.pbxuser(6KB)
--------project.pbxproj(13KB)
--------xcuserdata()
----.DS_Store(12KB)
----Classes()
--------CustomSegmentedViewController.m(5KB)
--------CustomSegmentedAppDelegate.m(3KB)
--------CQSegmentControl.h(2KB)
--------CustomSegmentedAppDelegate.h(525B)
--------CQSegmentControl.m(20KB)
--------CustomSegmentedViewController.h(260B)
----CustomSegmented-Info.plist(909B)
----MainWindow.xib(20KB)
----left_normal.png(3KB)