最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS實(shí)現(xiàn)簡(jiǎn)單分欄效果

 更新時(shí)間:2022年03月21日 12:01:08   作者:小溪彼岸  
這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)簡(jiǎn)單分欄效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了iOS實(shí)現(xiàn)簡(jiǎn)單分欄效果的具體代碼,供大家參考,具體內(nèi)容如下

直接貼代碼嘍

GMSubfieldViiew.h

#import <UIKit/UIKit.h>

@interface GMSubfieldViiew : UIView

/**
?* select index
?*/
@property(nonatomic,copy) void(^clickIndex)(NSInteger index);

- (instancetype)initWithFrame:(CGRect)frame titles:(NSArray *)thiTitles;

/**
?* ?默認(rèn)勾選
?*/
@property(nonatomic,assign) NSInteger selectedIndex;

@end

GMSubfieldViiew.m

#import "GMSubfieldViiew.h"

#define lineH 2
@interface GMSubfieldViiew ()
/**
?* ?titles
?*/
@property(nonatomic,strong) NSArray * titles;
/**
?* ?lineView
?*/
@property(nonatomic,weak) UIView *lineView;
/**
?* ?itemWidth
?*/
@property(nonatomic,assign) CGFloat itemWidth;
@end

@implementation GMSubfieldViiew


#pragma mark - initUI
- (instancetype)initWithFrame:(CGRect)frame titles:(NSArray *)thiTitles
{
? ? if (self = [super initWithFrame:frame]) {
? ? ? ? self.titles = thiTitles;
? ? ? ? //initSubViews
? ? ? ? [self initSubViews];
? ? }
? ? return self;
}

#pragma mark - action
- (void) initSubViews
{
? ? self.itemWidth = kScreen_Width/self.titles.count;
? ? //add child
? ? for (int i=0; i<self.titles.count; i++) {
? ? ? ? UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
? ? ? ? [btn setTitle:self.titles[i] forState:UIControlStateNormal];
? ? ? ? btn.titleLabel.font = FontSize(15);
? ? ? ? btn.tag ?= 100+i;
? ? ? ? btn.layer.borderWidth = 0.5;
? ? ? ? [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
? ? ? ? btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
? ? ? ? [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
? ? ? ? [self addSubview:btn];
? ? }

? ? //添加下劃線
? ? UIView *lineView ?= [[UIView alloc]init];
? ? lineView.backgroundColor = [UIColor blackColor];
? ? [self addSubview:lineView];
? ? self.lineView ? ? = lineView;
}

- (void)layoutSubviews
{
? ? [super layoutSubviews];

? ? for (int i=0; i<self.titles.count; i++) {
? ? ? ? UIButton *btn = [self viewWithTag:100+i];
? ? ? ? btn.frame = CGRectMake(i*self.itemWidth, 0, self.itemWidth, self.bounds.size.height-lineH+1);
? ? }
? ? self.lineView.frame = CGRectMake(self.selectedIndex*self.itemWidth, self.bounds.size.height-lineH, self.itemWidth, lineH);
}


- (void) btnClick:(UIButton *)btn
{
? ? NSInteger index = btn.tag -100;
? ? ESWeakSelf
? ? [UIView animateWithDuration:0.2 animations:^{
? ? ? ? ESStrongSelf
? ? ? ? self.lineView.frame = CGRectMake(index*self.itemWidth, self.bounds.size.height-lineH, self.itemWidth, lineH);
? ? }];
? ? if (self.clickIndex) {
? ? ? ? self.clickIndex(index);
? ? }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
? ? // Drawing code
}
*/

@end

調(diào)用:

GMSubfieldViiew *segView = [[GMSubfieldViiew alloc]initWithFrame:CGRectMake(0, 10, kScreen_Width, segH) titles:@[@"未還",@"已還"]];
? ? segView.selectedIndex = 1;
? ? ESWeakSelf
? ? segView.clickIndex = ^(NSInteger index){
? ? ? ? self.isHK = NO;
? ? ? ? ESStrongSelf
? ? ? ? if(index==0){
? ? ? ? ? ? //未還
? ? ? ? ? ? self.rightButton.hidden = NO;
? ? ? ? }
? ? ? ? else if(index==1){
? ? ? ? ? ?//已還
? ? ? ? ? ? self.rightButton.hidden = YES;
? ? ? ? ? ? self.containView.hidden = YES;
? ? ? ? }
? ? ? ? self.tableView.frame = CGRectMake(0, 60, kScreen_Width, kScreen_Height-NavHeight-60);
? ? ? ? [self.tableView reloadData];
? ? };
? ?[self.view addSubView:segView];

效果圖:

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • ios 使用xcode11 新建項(xiàng)目工程的步驟詳解

    ios 使用xcode11 新建項(xiàng)目工程的步驟詳解

    這篇文章主要介紹了ios 使用xcode11 新建項(xiàng)目工程 (值得注意的問題),本文分步驟通過圖文的形式給大家展示,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-04-04
  • 支持Xcode10和適配iPhone XS Max、iPhone XR的方法

    支持Xcode10和適配iPhone XS Max、iPhone XR的方法

    這篇文章主要介紹了支持Xcode10和適配iPhone XS Max、iPhone XR的方法,文中通過示例代碼以及圖文介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-10-10
  • iOS超出父控件范圍無法點(diǎn)擊問題解決

    iOS超出父控件范圍無法點(diǎn)擊問題解決

    這篇文章主要介紹了iOS超出父控件范圍無法點(diǎn)擊問題解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-06-06
  • iOS 截取字符串中兩個(gè)指定字符串中間的字符串方法

    iOS 截取字符串中兩個(gè)指定字符串中間的字符串方法

    下面小編就為大家分享一篇iOS 截取字符串中兩個(gè)指定字符串中間的字符串方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • IOS應(yīng)用內(nèi)跳轉(zhuǎn)系統(tǒng)設(shè)置相關(guān)界面的方法

    IOS應(yīng)用內(nèi)跳轉(zhuǎn)系統(tǒng)設(shè)置相關(guān)界面的方法

    在iOS開發(fā)中,有時(shí)會(huì)有跳轉(zhuǎn)系統(tǒng)設(shè)置界面的需求,例如提示用戶打開藍(lán)牙或者WIFI,提醒用戶打開推送或者位置權(quán)限等,接下來通過本文給大家介紹IOS應(yīng)用內(nèi)跳轉(zhuǎn)系統(tǒng)設(shè)置相關(guān)界面的方法,喜歡的朋友參考下
    2016-02-02
  • iOS設(shè)置圓角的4種方法實(shí)例(附性能評(píng)測(cè))

    iOS設(shè)置圓角的4種方法實(shí)例(附性能評(píng)測(cè))

    這篇文章主要給大家介紹了關(guān)于iOS設(shè)置圓角的4種方法,并給大家附上了性能評(píng)測(cè),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-01-01
  • IOS 解決UIButton 點(diǎn)擊卡頓/延遲的問題

    IOS 解決UIButton 點(diǎn)擊卡頓/延遲的問題

    本文主要介紹 IOS UIButton, 這里給大家提供代碼實(shí)例作為參考,解決 UIButton 點(diǎn)擊卡頓或者延遲問題,在開發(fā) IOS 項(xiàng)目的小伙伴如果遇到這樣的問題可以參考下
    2016-07-07
  • 超精準(zhǔn)的iOS計(jì)步器實(shí)現(xiàn)代碼

    超精準(zhǔn)的iOS計(jì)步器實(shí)現(xiàn)代碼

    這篇文章主要為大家詳細(xì)介紹了超精準(zhǔn)的iOS計(jì)步器實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • IOS給xcode工程關(guān)聯(lián)pod的實(shí)例詳解

    IOS給xcode工程關(guān)聯(lián)pod的實(shí)例詳解

    這篇文章主要介紹了IOS給xcode工程關(guān)聯(lián)pod的實(shí)例詳解的相關(guān)資料,希望大家通過本文能實(shí)現(xiàn)這樣的需求,需要的朋友可以參考下
    2017-09-09
  • 查看iOS Crash logs的方法

    查看iOS Crash logs的方法

    發(fā)布了一個(gè)應(yīng)用,用戶使用 的時(shí)候crash了,現(xiàn)在想調(diào)查為何crash,所以想在這里探討一下如何查看iphone 手機(jī)的crash logs
    2015-06-06

最新評(píng)論

正阳县| 乌拉特后旗| 西平县| 卫辉市| 体育| 荆门市| 石门县| 威远县| 韶关市| 民权县| 天等县| 沭阳县| 涿鹿县| 万宁市| 海城市| 洛扎县| 建宁县| 西乌| 灵川县| 依兰县| 澄城县| 榕江县| 忻城县| 北京市| 辉县市| 确山县| 犍为县| 治县。| 南通市| 桐梓县| 黑龙江省| 石首市| 宽城| 休宁县| 德保县| 西和县| 宁晋县| 磐安县| 镇坪县| 淳化县| 安顺市|