从iPhone App Store重新创建分段控件 [英] Recreating Segmented Control from iPhone App Store

查看:52
本文介绍了从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重新创建分段控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆