开发者

Recreating Segmented Control from iPhone App Store

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 s开发者_开发百科egmented 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.

Recreating Segmented Control from iPhone App Store


You can use:

[mySegmentedControl setSegmentedControlStyle: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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜