扫码关注官方订阅号
如图中toolbar上的按钮,请问是如何实现这种透明样式的? 设计师说iOS有自带的,这个看着像segmentcontrol,但自带的segmentcontrol好像没这种样式的,请教高人如何实现这种透明样式的按钮?
ringa_lee
确实,原生代码可以实现,但我还是要谴责一下你的设计师,这样说是非常不负责任的。 贴一下示例代码:
UILabel *lb = [[UILabel alloc] initWithFrame:CGRectMake(100.0f, 190.0f, 20.0f, 60.0f)]; lb.backgroundColor = [UIColor blueColor]; [self.window addSubview:lb]; UILabel *lr = [[UILabel alloc] initWithFrame:CGRectMake(120.0f, 190.0f, 20.0f, 60.0f)]; lr.backgroundColor = [UIColor redColor]; [self.window addSubview:lr]; UILabel *ly = [[UILabel alloc] initWithFrame:CGRectMake(140.0f, 190.0f, 20.0f, 60.0f)]; ly.backgroundColor = [UIColor yellowColor]; [self.window addSubview:ly]; UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 200.0f, 320.0f, 44.0f)]; toolBar.barStyle = UIBarStyleBlackOpaque; toolBar.alpha = 0.9f; [self.window addSubview:toolBar]; UISegmentedControl *control = [[UISegmentedControl alloc] initWithItems:@[@"确定", @"取消"]]; control.tintColor = [UIColor blackColor]; control.segmentedControlStyle = UISegmentedControlStyleBar; control.enabled = NO; control.frame = CGRectMake(10.0f, 7.0f, 120.0f, 30.0f); [toolBar addSubview:control];
在ToolBar下边放了红黄蓝三个彩条,用来衬托ToolBar的透明。效果如图:
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
确实,原生代码可以实现,但我还是要谴责一下你的设计师,这样说是非常不负责任的。
贴一下示例代码:
在ToolBar下边放了红黄蓝三个彩条,用来衬托ToolBar的透明。效果如图:
