iOS如何實(shí)現(xiàn)左右可滑動的選擇條

這篇文章主要介紹iOS如何實(shí)現(xiàn)左右可滑動的選擇條,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

專注于為中小企業(yè)提供成都網(wǎng)站建設(shè)、成都網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)陽春免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

一,效果圖。

iOS如何實(shí)現(xiàn)左右可滑動的選擇條

二,工程圖。

iOS如何實(shí)現(xiàn)左右可滑動的選擇條

三,代碼。

RootViewController.h

#import <UIKit/UIKit.h>
@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:@"購車應(yīng)用",@"車主應(yīng)用", 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如何實(shí)現(xiàn)左右可滑動的選擇條”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)頁標(biāo)題:iOS如何實(shí)現(xiàn)左右可滑動的選擇條
瀏覽地址:http://bm7419.com/article32/igdppc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT網(wǎng)站制作、網(wǎng)站設(shè)計公司、建站公司、小程序開發(fā)、虛擬主機(jī)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司