Latest 0.1.4
Homepage https://github.com/lanhaiyang/HPSlideSegmentView
License MIT
Platforms ios 7.0, requires ARC
Authors

Pods

#在podfile 中添加

# iOS 版本要7.0 :platform :ios, ‘7.0’
pod 'HPSlideSegmentView', '~> 0.1.2’

创建悬浮效果

在下面的可以看到HPSlideSegmentControllerView对应的属性的用途:

image

属性slideBackgroungView

这个属性主要用于管理左右滑动模块
  • slideModuleView 文字滑动模块
  • slideSegmenView 视图滑动模块

slideSegmenView 里面的 cacheMaxCount 属性

缓存个数
小于3默认为3

@property(nonatomic,assign) NSUInteger cacheMaxCount;

第一种样式初始化HPSlideSegmentControllerView

image

在 ViewController.h


# import "HPSlideSegmentControllerView.h"

@interface DemoViewController : HPSlideSegmentControllerView

@end

在 ViewController.m

  • 创建headeView

UIView *headerView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200)];
headerView.backgroundColor=[UIColor blueColor];

self.headeView=headerView;

第二种样式初始化HPSlideSegmentBackgroundView

image

创建


HPSlideSegmentBackgroundView *slideSegmentBackgroundView=[[HPSlideSegmentBackgroundView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64)];

[self.view addSubview:slideSegmentBackgroundView];  

实现

数据设置

  • 告诉我滑模块的内容 告诉父类的contents对象
//NSString 数据源
self.slideBackgroungView.contents=self.dataSouce;

实现对应的代理

  • 现在你需要显示多少数据 告诉<HPSlideSegmentBackgroundDataSource>代理
self.slideBackgroungView.dataSource=self;

//代理
-(NSUInteger)hp_slideListWithCount
{
    return self.dataSouce.count;//个数
}
  • 在来需要你要在对应模块中显示什么 告诉<HPSlideSegmentViewDataSouce>代理
self.slideBackgroungView.slideSegmenView.dataSource=self;

//代理
-(void )hp_slideListWithViewController:(HPSlideModel *)slideSegmentView index:(NSUInteger)index
{
    AViewController *aViewController=[[AViewController alloc] init];

    aViewController.title=self.dataSouce[index];
    slideSegmentView.mainSlideScrollView=aViewController.tabelView;
    slideSegmentView.showViewController=aViewController;
}

如果是使用storyboard

-(void )hp_slideListWithViewController:(HPSlideModel *)slideSegmentView index:(NSUInteger)index
{
HomeViewController *homeViewController=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
        [homeViewController.view layoutIfNeeded];//更新一下
  slideSegmentView.mainSlideScrollView=homeViewController.scrollView;
        slideSegmentView.showViewController=homeViewController;

}
  • 还有需要注意的是在<HPSlideSegmentViewDataSouce>代理中
-(void )hp_slideListWithViewController:(HPSlideModel *)slideSegmentView index:(NSUInteger)index

HPSlideModel

  • showViewController

    这个用于显示对应UIViewController

  • mainSlideScrollView

    这个属性 showViewController 上面显示的UIScrollView 这个用于处理手势冲突(如果没有手势冲突问题这个不需要传)

Latest podspec

{
    "name": "HPSlideSegmentView",
    "version": "0.1.4",
    "summary": "HPSlideSegmentView u6ed1u52a8u60acu505cu548cu4fa7u6ed1u6846u67b6",
    "homepage": "https://github.com/lanhaiyang/HPSlideSegmentView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "lanhaiyang": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/lanhaiyang/HPSlideSegmentView.git",
        "tag": "0.1.4"
    },
    "source_files": "HPSlideSegmentView/HPSlideSegmenView/*.{h,m}",
    "requires_arc": true,
    "subspecs": [
        {
            "name": "BaseView",
            "source_files": "HPSlideSegmentView/HPSlideSegmenView/BaseView/*.{h,m}"
        },
        {
            "name": "Tool",
            "source_files": "HPSlideSegmentView/HPSlideSegmenView/Tool/*.{h,m}"
        },
        {
            "name": "Manage",
            "resources": "HPSlideSegmentView/HPSlideSegmenView/Tool/*.{h,m}",
            "source_files": "HPSlideSegmentView/HPSlideSegmenView/Manage/*.{h,m}"
        }
    ]
}

Pin It on Pinterest

Share This