スライダースイッチYORKページフレームについてのiOS模造カスタム

FSScrollContentView

GitHubの:https://github.com/shunFSKi/FSScrollContentView
彼が統合プロジェクト中にパッケージを並べ替え、より実践的なビジネスコードのためのフレームワークを引き抜く、理解しやすいです。
コンテンツ領域はまた、タイトルの上にスライドスイッチをサポートしています下の、ページの内容の下に切り替える、サポート上のタイトルをクリックします。

  • 主にいくつかのビューについてのスライド、トップラベルのニーズにスイッチング制御を示すビューに適用するために使用されます
  • イミテーション網易ニュース、電気の供給者の一部は、スタイルアプリを達成するために
  • シンプルで理解しやすい、それはいくつかの単純なカスタムをサポートしています
  • 自動的にラベルの数を適応させるか、コントロールスライダーをスライドすることはできません

レンダリング

scrollContentView.gif

使用

1、cocoapods

pod search FSScrollContentView 
如果找不到执行pod setup
pod 'FSScrollContentView'

2、ファイルを追加

FSScrollContentViewLibファイルには、独自のプロジェクト、ヘッダファイルのインポートをインポートするプロジェクトフォルダにクローンコードを指示するFSScrollContentView.h

API命令

実際には、デモは非常に詳細なメモを持って、理解しやすい
フレームワークが含まれていFSPageContentViewFSSegmentTitleView文書の2つの完全に独立した種類を適宜用いることができます

FSPageContentView

  • FSPageContentViewを作成します
/**
 对象方法创建FSPageContentView

 @param frame frame
 @param childVCs 子VC数组
 @param parentVC 父视图VC
 @param delegate delegate
 @return FSPageContentView
 */
- (instancetype)initWithFrame:(CGRect)frame childVCs:(NSArray *)childVCs parentVC:(UIViewController *)parentVC delegate:(id<FSPageContentViewDelegate>)delegate; 
  • FSPageContentView属性変更
/**
 设置contentView当前展示的页面索引,默认为0
 */
@property (nonatomic, assign) NSInteger contentViewCurrentIndex; 
  • FSPageContentViewプロキシ方法
/**
 FSPageContentView开始滑动

 @param contentView FSPageContentView
 */
- (void)FSContentViewWillBeginDragging:(FSPageContentView *)contentView;

/**
 FSPageContentView滑动调用

 @param contentView FSPageContentView @param startIndex 开始滑动页面索引 @param endIndex 结束滑动页面索引 @param progress 滑动进度 */ - (void)FSContentViewDidScroll:(FSPageContentView *)contentView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex progress:(CGFloat)progress; /** FSPageContentView结束滑动 @param contentView FSPageContentView @param startIndex 开始滑动索引 @param endIndex 结束滑动索引 */ - (void)FSContenViewDidEndDecelerating:(FSPageContentView *)contentView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex; 

FSSegmentTitleView

  • FSSegmentTitleViewを作成します
/**
 对象方法创建FSSegmentTitleView

 @param frame frame
 @param titlesArr 标题数组,必须传值
 @param delegate delegate
 @param incatorType 指示器类型 @return FSSegmentTitleView */ - (instancetype)initWithFrame:(CGRect)frame titles:(NSArray *)titlesArr delegate:(id<FSSegmentTitleViewDelegate>)delegate indicatorType:(FSIndicatorType)incatorType; 
  • FSSegmentTitleView属性変更

/ **
タイトルアレイは値を渡さなければならない
* /
@Property(非アトミック、強い)にNSArray * titlesArr。
放棄された/DEPRECATED_1.0.1

/**
 标题文字间距,默认20
 */
@property (nonatomic, assign) CGFloat itemMargin; /** 当前选中标题索引,默认0 */ @property (nonatomic, assign) NSInteger selectIndex; /** 标题字体大小,默认15 */ @property (nonatomic, strong) UIFont *titleFont; /** 标题正常颜色,默认black */ @property (nonatomic, strong) UIColor *titleNormalColor; /** 标题选中颜色,默认red */ @property (nonatomic, strong) UIColor *titleSelectColor; /** 指示器颜色,默认与titleSelectColor一样,在FSIndicatorTypeNone下无效 */ @property (nonatomic, strong) UIColor *indicatorColor; /** 在FSIndicatorTypeCustom时可自定义此属性,为指示器一端延伸长度,默认5 */ @property (nonatomic, assign) CGFloat indicatorExtension; 
  • FSSegmentTitleViewプロキシ方法
/**
 切换标题

 @param titleView FSSegmentTitleView
 @param startIndex 切换前标题索引
 @param endIndex 切换后标题索引
 */
- (void)FSSegmentTitleView:(FSSegmentTitleView *)titleView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex; 
  • FSSegmentTitleView列挙型
typedef enum : NSUInteger {
    FSIndicatorTypeDefault,//默认与按钮长度相同
    FSIndicatorTypeEqualTitle,//与文字长度相同 FSIndicatorTypeCustom,//自定义文字边缘延伸宽度 FSIndicatorTypeNone, } FSIndicatorType;//指示器类型枚举 

例えば

詳細は、デモを使用して表示することができます

self.titleView = [[FSSegmentTitleView alloc]initWithFrame:CGRectMake(0, 64, CGRectGetWidth(self.view.bounds), 50) delegate:self indicatorType:0]; self.titleView.titlesArr = @[@"全部",@"服饰穿搭",@"生活百货",@"美食吃货",@"美容护理",@"母婴儿童",@"数码家电",@"其他"]; [self.view addSubview:_titleView]; NSMutableArray *childVCs = [[NSMutableArray alloc]init]; for (NSString *title in self.titleView.titlesArr) { ChildViewController *vc = [[ChildViewController alloc]init]; vc.title = title; [childVCs addObject:vc]; } self.pageContentView = [[FSPageContentView alloc]initWithFrame:CGRectMake(0, 114, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) - 90) childVCs:childVCs parentVC:self delegate:self]; [self.view addSubview:_pageContentView]; - (void)FSSegmentTitleView:(FSSegmentTitleView *)titleView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex { self.pageContentView.contentViewCurrentIndex = endIndex; } - (void)FSContenViewDidEndDecelerating:(FSPageContentView *)contentView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex { self.titleView.selectIndex = endIndex; } 

  • 2017年4月28日- > 1.0初版
  • 2017年5月7日- > 1.0.1カスタムテキストサイズの種類を選択し、タイトルを追加し、初期化メソッドを変更


著者:PURE脂肪青い
リンクします。https://www.jianshu.com/p/34cecb066cc1
出典:ジェーン・ブック
著者によって予約ジェーンブックの著作権は、いかなる形で再現され、承認を得るために、作者に連絡して、ソースを明記してください。

おすすめ

転載: www.cnblogs.com/Free-Thinker/p/11121268.html