iOS开关按钮自定义指南

可以设置开关的颜色和修改字符串等。例如,使用图片替代: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;
zip
CustomSegmented(自定义开关按钮).zip 预估大小:29个文件
folder
CustomSegmented(自定义开关按钮) 文件夹
file
main.m 367B
file
left_press.png 4KB
file
right_normal.png 3KB
file
CustomSegmented_Prefix.pch 199B
file
CustomSegmentedViewController.xib 7KB
file
right_press.png 4KB
folder
CustomSegmented.xcodeproj 文件夹
file
qiancheng.mode1v3 40KB
folder
project.xcworkspace 文件夹
file
contents.xcworkspacedata 160B
folder
xcuserdata 文件夹
folder
guanz.xcuserdatad 文件夹
file
UserInterfaceState.xcuserstate 12KB
folder
qiancheng.xcuserdatad 文件夹
file
UserInterfaceState.xcuserstate 14KB
folder
guanzhong.xcuserdatad 文件夹
file
UserInterfaceState.xcuserstate 7KB
file
qiancheng.pbxuser 6KB
file
project.pbxproj 13KB
folder
xcuserdata 文件夹
folder
guanz.xcuserdatad 文件夹
folder
xcschemes 文件夹
file
CustomSegmented.xcscheme 3KB
file
xcschememanagement.plist 487B
folder
qiancheng.xcuserdatad 文件夹
folder
xcschemes 文件夹
file
CustomSegmented.xcscheme 3KB
file
xcschememanagement.plist 487B
folder
guanzhong.xcuserdatad 文件夹
folder
xcschemes 文件夹
file
CustomSegmented.xcscheme 3KB
file
xcschememanagement.plist 487B
file
.DS_Store 12KB
folder
Classes 文件夹
file
CustomSegmentedViewController.m 5KB
file
CustomSegmentedAppDelegate.m 3KB
file
CQSegmentControl.h 2KB
file
CustomSegmentedAppDelegate.h 525B
file
CQSegmentControl.m 20KB
file
CustomSegmentedViewController.h 260B
file
CustomSegmented-Info.plist 909B
file
MainWindow.xib 20KB
file
left_normal.png 3KB
zip 文件大小:86.39KB