从iPhone App Store重新创建分段控件

编程入门 行业动态 更新时间:2024-10-25 23:28:56
本文介绍了从iPhone App Store重新创建分段控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用导航栏和位于其正下方的分段控件来重新创建类似于应用商店的界面.我的控制器和所有关联的视图都能正常工作;我的问题是我想将分段控制器的颜色与苹果在商店中使用的颜色进行匹配.我将如何实现这一目标?我已经尝试过colorWithRed:green:blue:alpha,但收效甚微.谢谢.

I'm trying to recreated an interface similar to the app store, using a navigation bar with a segmented control directly below it. I have the controller and all associated views working perfectly; my problem is that I would like to match the color of my segmented controller to the same color that apple uses in the store. How would I go about achieving this? I've experimented with colorWithRed:green:blue:alpha but with little success. Thanks.

推荐答案

您可以使用:

[mySegmentedControl setSegmentedControlStyle:7];

但是,尽管我听说应用程序通过得还算不错,但有可能会被App Store拒绝,但是您必须确保iOS的更新不会更改7以后的数字.

however it is possible that this will be rejected from the App Store, although I have heard of apps that got through perfectly alright, you will have to make sure though that updates to iOS don't change the number from 7.

或者将条形设置为 UISegmentedControlStyleBar ,然后在其后添加一个UIImageView,并带有蓝色背景边缘的1x44px屏幕截图:

Alternatively you set the bar style to UISegmentedControlStyleBar and add a UIImageView behind it with and 1x44px screenshot of the edge of the blue background:

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTitles]; [segmentedControl setFrame:CGRectMake(5, 7, self.view.bounds.size.width - 10, 30)]; [segmentedControl setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; [segmentedControl setSegmentedControlStyle:UISegmentedControlStyleBar]; UIImageView *backgroundOfSegmentedControl = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"segmentedControl7Background"]]; [backgroundOfSegmentedControl setFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)]; [backgroundOfSegmentedControl setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; [self.view addSubview:backgroundOfSegmentedControl]; [self.view addSubview:segmentedControl];

结果并不完全相同,但是除非直接将它们相互比较,否则您不会注意到.

The result is not identical, but you won't notice unless you directly compare them next to each other.

更多推荐

从iPhone App Store重新创建分段控件

本文发布于:2023-11-04 01:14:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1556553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   iPhone   App   Store

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!