1. 首页
  2. 移动开发
  3. iOS
  4. 自定义开关按钮(ios)

自定义开关按钮(ios)

上传者: 2018-12-09 09:59:15上传 ZIP文件 86.39KB 热度 84次
可以设置开关的颜色,修改字符串等。例如,用图片代替: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 mai nBundle] 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;
用户评论
码姐姐匿名网友 2018-12-09 09:59:15

差不多意思

码姐姐匿名网友 2018-12-09 09:59:15

可以使用,OK

码姐姐匿名网友 2018-12-09 09:59:15

还可以,基本符合我要的