这个控件结合了优秀的HMSegmentedControl和负责在点击HMSegmentedControl时显示正确页面以及在UIPageviewController滚动时更新选择的UIPageviewController。
或者将此仓库中的THSegmentedPager/
目录复制到你的项目中。
如果你偏好手动方法,请注意你需要导入依赖项,在这个例子中是
这将导致一些找不到导入的错误,你也需要手动解决这些问题。
以下是从ExampleProject中获取的示例初始化代码。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
THSegmentedPager *pager = (THSegmentedPager *)self.window.rootViewController;
NSMutableArray *pages = [NSMutableArray new];
for (int i = 1; i < 4; i++) {
// Create a new view controller and pass suitable data.
SamplePagedViewController *pagedViewController = [pager.storyboard instantiateViewControllerWithIdentifier:@"SamplePagedViewController"];
[pagedViewController setViewTitle:[NSString stringWithFormat:@"Page %d",i]];
[pagedViewController.view setBackgroundColor:[UIColor colorWithHue:((i/8)%20)/20.0+0.02 saturation:(i%8+3)/10.0 brightness:91/100.0 alpha:1]];
[pages addObject:pagedViewController];
}
[pager setPages:pages];
return YES;
}
……是非常受欢迎的。如果你有一个想法,只需分叉库进行改动,如果它对他人有用并且不影响其他用户的图书馆功能,我会将其插入
本项目的源代码按照MIT许可证标准提供。请参阅许可证文件。