欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS?Segment帶滑動條切換效果

 更新時間:2022年03月21日 11:06:09   作者:長沙火山  
這篇文章主要為大家詳細介紹了iOS?Segment帶滑動條切換,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了iOS Segment帶滑動條切換效果的具體代碼,供大家參考,具體內(nèi)容如下

#import "ViewController.h"
?
@interface ViewController ()
?
@property (nonatomic,strong) NSArray *arrTitle;
?
@property (nonatomic,strong) UIView *flyBar;
?
@end
?
@implementation ViewController
?
- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? // Do any additional setup after loading the view, typically from a nib.
? ??
? ? _arrTitle = [[NSArray alloc] initWithObjects:@"標題1",@"標題2",@"標題3",@"標題4", nil];
? ??
? ? UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
? ? baseView.backgroundColor = [UIColor orangeColor];
? ? [self.view addSubview:baseView];
? ??
? ? for (int i=0; i<_arrTitle.count; i++) {
? ? ? ? UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/_arrTitle.count*i, 20,self.view.frame.size.width/_arrTitle.count, 40)];
? ? ? ? [btn setTitle:[_arrTitle objectAtIndex:i] forState:UIControlStateNormal];
? ? ? ? [btn setTag:100+i];
? ? ? ? [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
? ? ? ? [baseView addSubview:btn];
? ? }
? ??
? ? _flyBar = [[UIView alloc] initWithFrame:CGRectMake(0, baseView.frame.size.height-2, self.view.frame.size.width/_arrTitle.count, 2)];
? ? _flyBar.backgroundColor = [UIColor redColor];
? ? [baseView addSubview:_flyBar];
}
?
- (void)btnClick:(id)sender
{
? ? NSInteger tagNum = [sender tag];
? ? [self updateButtonClickState:tagNum];
}
?
//更新按鈕點擊效果
- (void)updateButtonClickState:(NSInteger)tagNum
{
? ? UIButton *currentBtn = (UIButton *)[self.view viewWithTag:tagNum];
? ??
? ? for (int i=100; i<_arrTitle.count+100; i++) {
? ? ? ? if (i != tagNum) {
? ? ? ? ? ? UIButton *btn = (UIButton *)[self.view viewWithTag:i];
? ? ? ? ? ? [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
? ? ? ? }
? ? }
? ??
? ? [UIView animateKeyframesWithDuration:0.1
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?delay:0.0
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?options:UIViewKeyframeAnimationOptionLayoutSubviews
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? animations:^{
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? _flyBar.center = CGPointMake(currentBtn.center.x, _flyBar.center.y);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? completion:^(BOOL finished) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [currentBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }];
}
?
?
@end

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • iOS自定義轉(zhuǎn)場動畫的幾種情況

    iOS自定義轉(zhuǎn)場動畫的幾種情況

    這篇文章主要給大家介紹了關于iOS自定義轉(zhuǎn)場動畫的幾種情況,文中通過示例代碼介紹的非常詳細,對各位iOS開發(fā)者們具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-06-06
  • iOS開發(fā)之UIScrollView詳解

    iOS開發(fā)之UIScrollView詳解

    UIScrollView使用非常廣,本文研究UIScrollView各屬性和方法,明白它們的意義、作用。這里我們整理UIScrollView一些常見用法以及一些效果的實現(xiàn)思路。
    2016-04-04
  • IOS繪制虛線的方法總結

    IOS繪制虛線的方法總結

    這篇文章給大家分享了iOS中繪制虛線常見的幾種方式,大家可以根據(jù)自己的需求進行選擇哪種方法,下面跟著小編來一起看看吧。
    2016-09-09
  • iOS應用開發(fā)中UIView添加邊框顏色及設置圓角邊框的方法

    iOS應用開發(fā)中UIView添加邊框顏色及設置圓角邊框的方法

    這篇文章主要介紹了iOS應用開發(fā)中UIView添加邊框顏色及設置圓角邊框的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下
    2016-02-02
  • 詳解iOS 用于解決循環(huán)引用的block timer

    詳解iOS 用于解決循環(huán)引用的block timer

    這篇文章主要介紹了詳解iOS 用于解決循環(huán)引用的block timer,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-12-12
  • iOS自定義雷達掃描擴散動畫

    iOS自定義雷達掃描擴散動畫

    這篇文章主要為大家詳細介紹了iOS自定義雷達掃描擴散動畫,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • iOS實現(xiàn)文本分頁的方法示例

    iOS實現(xiàn)文本分頁的方法示例

    這篇文章主要給大家介紹了關于iOS實現(xiàn)文本分頁的相關資料,文中通過示例代碼介紹的非常詳細,對各位iOS開發(fā)者們具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-09-09
  • iOS NSURLSessionDownloadTask設置代理文件下載的示例

    iOS NSURLSessionDownloadTask設置代理文件下載的示例

    本篇文章主要介紹了iOS NSURLSessionDownloadTask設置代理文件下載的示例,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-01-01
  • IOS CoreLocation實現(xiàn)系統(tǒng)自帶定位的方法

    IOS CoreLocation實現(xiàn)系統(tǒng)自帶定位的方法

    本篇文章主要介紹了IOS Core Location實現(xiàn)系統(tǒng)自帶定位的方法,非常具有實用價值,需要的朋友可以參考下。
    2017-02-02
  • iOS新版微信底部工具欄遮擋問題完美解決

    iOS新版微信底部工具欄遮擋問題完美解決

    這篇文章主要介紹了iOS新版微信底部工具欄遮擋問題完美解決,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-03-03

最新評論