标签:ios 控件 uisegmentedcontrol hmsegmentedcontrol ios8编程
郝萌主倾心贡献,尊重作者的劳动成果,请勿转载。
如果文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额随意,重在心意^_^
我要捐赠: 点击捐赠
Cocos2d-X源码下载:点我传送
HMSegmentedControl 是 UISegmentedControl 的替代品,模仿了 Google Currents 使用的效果。
A drop-in replacement for UISegmentedControl mimicking the style of the segmented control used in Google Currents and various other Google products.
The easiest way of installing HMSegmentedControl is via CocoaPods.
pod ‘HMSegmentedControl‘, ‘~> 1.1.0‘
If you haven‘t heard about CocoaPods (seriously, where were you?!), it‘s a dependency manager for Xcode projects that provides very simple installation of libraries. Here‘s how to get started.
Install CocoaPods if not already available:
$ [sudo] gem install cocoapods
$ pod setup
Change to the directory of your Xcode project, and Create and Edit your Podfile and add HMSegmentedControl:
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
platform :ios, ‘5.0‘
pod ‘HMSegmentedControl‘, ‘~> 1.2.0‘
Install into your project:
$ pod install
Open your project in Xcode from the .xcworkspace file (not the usual project file)
$ open MyProject.xcworkspace
HMSegmentedControl.h
and HMSegmentedControl.m
to
your project.QuartzCore.framework
to
your linked frameworks.#import "HMSegmentedControl.h"
where
you want to add the control.The code below will create a segmented control with the default looks:
HMSegmentedControl *segmented = [[HMSegmentedControl alloc] initWithSectionTitles:@[@"已收公告",@"已发公告"]]; segmented.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth; segmented.frame = CGRectMake(self.view.bounds.size.width/2-100, 4, 200, 40); segmented.backgroundColor = [UIColor clearColor]; segmented.selectionIndicatorHeight = 3.0f; segmented.font = [UIFont fontWithName:@"STHeitiSC-Light" size:19.0f]; segmented.textColor = WHRGB(255, 175, 185); segmented.selectedTextColor = [UIColor whiteColor]; segmented.selectionIndicatorColor = [UIColor whiteColor]; segmented.selectionStyle = HMSegmentedControlSelectionStyleFullWidthStripe; segmented.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown; [segmented addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged]; self.segmentedControl = segmented; [self.navigationController.navigationBar addSubview:segmented];
郝萌主倾心贡献,尊重作者的劳动成果,请勿转载。
如果文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额随意,重在心意^_^
我要捐赠: 点击捐赠
Cocos2d-X源码下载:点我传送
标签:ios 控件 uisegmentedcontrol hmsegmentedcontrol ios8编程
原文地址:http://blog.csdn.net/haomengzhu/article/details/46485465