KPageView
所属分类:WEB开发
开发工具:Objective-C
文件大小:0KB
下载次数:0
上传日期:2017-07-15 09:59:23
上 传 者:
sh-1993
说明: KPageView 模仿网易新闻选项卡、PageViewController、PageView,
(KPageView imitates NetEase News tab, PageViewController, PageView,)
文件列表:
.DS_Store (6148, 2017-07-15)
CollectionView模式.gif (167558, 2017-07-15)
KPageView.xcodeproj/ (0, 2017-07-15)
KPageView.xcodeproj/project.pbxproj (17219, 2017-07-15)
KPageView.xcodeproj/project.xcworkspace/ (0, 2017-07-15)
KPageView.xcodeproj/project.xcworkspace/contents.xcworkspacedata (154, 2017-07-15)
KPageView.xcodeproj/project.xcworkspace/xcuserdata/ (0, 2017-07-15)
KPageView.xcodeproj/project.xcworkspace/xcuserdata/k.xcuserdatad/ (0, 2017-07-15)
KPageView.xcodeproj/project.xcworkspace/xcuserdata/k.xcuserdatad/UserInterfaceState.xcuserstate (39294, 2017-07-15)
KPageView.xcodeproj/xcuserdata/ (0, 2017-07-15)
KPageView.xcodeproj/xcuserdata/k.xcuserdatad/ (0, 2017-07-15)
KPageView.xcodeproj/xcuserdata/k.xcuserdatad/xcdebugger/ (0, 2017-07-15)
KPageView.xcodeproj/xcuserdata/k.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist (473, 2017-07-15)
KPageView.xcodeproj/xcuserdata/k.xcuserdatad/xcschemes/ (0, 2017-07-15)
KPageView.xcodeproj/xcuserdata/k.xcuserdatad/xcschemes/KPageView.xcscheme (3327, 2017-07-15)
KPageView.xcodeproj/xcuserdata/k.xcuserdatad/xcschemes/xcschememanagement.plist (481, 2017-07-15)
KPageView/ (0, 2017-07-15)
KPageView/AppDelegate.h (275, 2017-07-15)
KPageView/AppDelegate.m (2037, 2017-07-15)
KPageView/Assets.xcassets/ (0, 2017-07-15)
KPageView/Assets.xcassets/AppIcon.appiconset/ (0, 2017-07-15)
KPageView/Assets.xcassets/AppIcon.appiconset/Contents.json (1077, 2017-07-15)
KPageView/Base.lproj/ (0, 2017-07-15)
KPageView/Base.lproj/LaunchScreen.storyboard (1740, 2017-07-15)
KPageView/Base.lproj/Main.storyboard (1689, 2017-07-15)
KPageView/Info.plist (1442, 2017-07-15)
KPageView/KContentView.h (730, 2017-07-15)
KPageView/KContentView.m (4996, 2017-07-15)
KPageView/KPageStyle.h (1469, 2017-07-15)
KPageView/KPageStyle.m (820, 2017-07-15)
KPageView/KPageView.h (1295, 2017-07-15)
KPageView/KPageView.m (7085, 2017-07-15)
KPageView/KPageViewLayout.h (522, 2017-07-15)
KPageView/KPageViewLayout.m (2502, 2017-07-15)
KPageView/KTitleView.h (592, 2017-07-15)
KPageView/KTitleView.m (11609, 2017-07-15)
KPageView/UIView+KExtension.h (793, 2017-07-15)
KPageView/UIView+KExtension.m (1812, 2017-07-15)
KPageView/ViewController.h (213, 2017-07-15)
... ...
# KPageView
KPageView 模仿网易新闻选项卡、PageViewController、PageView
##
控制器模式
![(控制器模式)](https://github.com/Kratos28/KPageView/blob/master/控制器模式.gif)
```objc
#import "ViewController.h"
#import "KPageStyle.h"
#import "UIView+KExtension.h"
#import "KPageView.h"
#import "KPageViewLayout.h"
@interface ViewController ()
@end
@implementation ViewController
static NSString *kCollectionViewCellID = @"kCollectionViewCellID";
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
KPageStyle *style = [[KPageStyle alloc]init];
//tileView是否可以滚动
style.isScrollEnable = YES;
//tileView是否可以缩放
// style.isScaleEnable = YES;
//tileView是否有揭盖
// style.isShowCoverView = YES;
//tileView是否有下划线
style.isShowBottomLine = YES;
NSArray *titles = @[@"123", @"游戏", @"haha游戏", @"ha", @"hahahaha", @"haha", @"fff", @"weff",@"wer"];
NSMutableArray *childVC = [NSMutableArray array];
for (NSString *titile in titles) {
UIViewController *vc = [[UIViewController alloc]init];
vc.view.backgroundColor = [UIColor colorWithRed:arc4random() %255/255.0 green:arc4random() %255/255.0 blue:arc4random() %255/255.0 alpha:1];
[childVC addObject:vc];
}
CGRect pageFrame = CGRectMake(0, 64, self.view.width, self.view.height -64);
KPageView *pageView = [[KPageView alloc]initWithFrame:pageFrame style:style titles:titles childVcs:childVC parentVc:self];
pageView.backgroundColor = [UIColor blueColor];
[self.view addSubview:pageView];
}
@end
```
## CollectionView模式
![(CollectionView模式)](https://github.com/Kratos28/KPageView/blob/master/CollectionView模式.gif)
```objc
#import "ViewController.h"
#import "KPageStyle.h"
#import "UIView+KExtension.h"
#import "KPageView.h"
#import "KPageViewLayout.h"
@interface ViewController ()
@end
@implementation ViewController
static NSString *kCollectionViewCellID = @"kCollectionViewCellID";
- (void)viewDidLoad {
[super viewDidLoad];
//TiteView的样式对象
KPageStyle *style = [[KPageStyle alloc]init];
//tileView是否可以滚动
style.isScrollEnable = NO;
//collectionView布局方式
KPageViewLayout *layout = [[KPageViewLayout alloc]init];
//上下左右边距
layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
//行间距
layout.lineSpacing = 10;
//列间距
layout.itemSpacing = 10;
//设置多少列
layout.cols = 4;
//设置多少行
layout.rows = 2;
NSArray *titles = @[@"123", @"游戏游戏游戏", @"haha游戏",@"ads"];
CGRect pageFrame = CGRectMake(0, 64, self.view.width,300);
KPageView *pageView = [[KPageView alloc]initWithFrame:pageFrame style:style titles:titles layout:layout];
pageView.dataSource = self;
pageView.delegate = self;
[pageView registerCell:[UICollectionViewCell class] identifier:kCollectionViewCellID];
pageView.backgroundColor = [UIColor blueColor];
[self.view addSubview:pageView];
}
- (NSInteger)numberOfSectionInPageView:(KPageView *)pageView
{
return 4;
}
- (NSInteger)pageView:(KPageView *)pageView numberOfItemInSection:(NSInteger)section
{
if (section == 0) {
return 12;
} else if (section == 1) {
return 30;
} else if (section == 2) {
return 7;
}
return 13;
}
- (UICollectionViewCell *)pageView:(KPageView *)pageView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [pageView dequeueReusableCell:kCollectionViewCellID forIndexPath:indexPath];
cell.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0f green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255) /255.0f alpha:1];
return cell;
}
@end
```
近期下载者:
相关文件:
收藏者: