新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

iOS如何实现左右可滑动的选择条-创新互联

这篇文章主要介绍iOS如何实现左右可滑动的选择条,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

成都创新互联公司专业为企业提供乌恰网站建设、乌恰做网站、乌恰网站设计、乌恰网站制作等企业网站建设、网页设计与制作、乌恰企业网站模板建站服务,十年乌恰做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

一,效果图。

iOS如何实现左右可滑动的选择条

二,工程图。

iOS如何实现左右可滑动的选择条

三,代码。

RootViewController.h

#import 
@interface RootViewController : UIViewController
@end

RootViewController.m

#import "RootViewController.h"
//引入头文件
#import "SVSegmentedControl.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
    // Custom initialization
  }
  return self;
}
- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  //初始化背景图
  [self initBackgroundView];
}
#pragma -makr -funcitons
-(void)initBackgroundView
{
  SVSegmentedControl *options = [[SVSegmentedControl alloc] initWithSectionTitles:[NSArray arrayWithObjects:@"购车应用",@"车主应用", nil]];
  options.center=CGPointMake(160, 100);
  [options setSelectedSegmentIndex:0 animated:NO];
  [options addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];
  [self.view addSubview:options];
}
#pragma -mark -doClickAction
- (void)segmentedControlChangedValue:(SVSegmentedControl*)segmentedControl {
  NSLog(@"--index--%i-", segmentedControl.selectedSegmentIndex);
}
- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}

以上是“iOS如何实现左右可滑动的选择条”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联网站建设公司行业资讯频道!

另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站栏目:iOS如何实现左右可滑动的选择条-创新互联
转载注明:http://www.wjwzjz.com/article/dsppcs.html
在线咨询
服务热线
服务热线:028-86922220
TOP