UIPage Control定制样式NatGeo [英] UIPage Control custom style NatGeo

查看:128
本文介绍了UIPage Control定制样式NatGeo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有UIView通过使用水平scrollView。要滚动视图,我使用了classimo方法 [self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@name Storyboard ID]];

In my app I have UIView that flow through the use of a horizontal scrollView. To scroll the view I used the classimo method [self addChildViewController: [self.storyboard instantiateViewControllerWithIdentifier: @ "name Storyboard ID"]];

每个UIView都遵循使用UIPageControl经典,但我不喜欢它,所以我想创建这样的东西(见图)

Each UIView is followed through the use of UIPageControl classic, but I do not like it and so I wanted to create something like this (see photo)

正如您从上面的图片中看到的那样,有一个三角形朝下的菜单,指示页面,通过scrollView上的水平滑动从一个主题传递给另一个用户

as you can see from the images above application there is a menu with a triangle pointing down, Indicating the page, passing from one topic to another user through the horizontal swipe on the scrollView

换句话说,国家地理不是使用经典镜头来管理页面,而是使用了一个指向下方的三角形和用户所在页面的标题...

In other words, instead of having the classic shot for the management of the pages, the National Geographic has used a triangle pointing down and the title of the page on which the user is ...

有人可以帮我理解如何创建类似的PageControl吗?

Could someone help me understand how can 'be created a similar PageControl?


推荐答案

有很多方法可以实现这一点。也许自定义 PageControl 不会是 UIPageControl 的子类。

例如,您可以继承 UIView ,并在其中放入 UIScrollView 。然后将一堆 UIButton 连续放入 UIScrollView ,每个都有一个标题是你的页面标题。当你点击一个按钮(你可以通过 UIButton -addTarget:action:forControlEvents:)获得此事件,你可以将点按的按钮滚动到正确的位置,突出显示它,并在它下面放一个小三角形。

有很多种可能性。比如说,您可以用 UILabel 替换按钮,并添加 UITapGestureRecognizer 来捕获用户点击,或者您可以替换 UIScrollView UITableView 如果你得到一长串页面(当然会引入一些复杂性)。你只需要选择自己喜欢的并尝试一下。

There are a lot of approaches to implement this. Maybe the custom PageControl won't be the subclass of a UIPageControl.
For example, you can subclass a UIView, and put a UIScrollView in it. And then put a bunch of UIButtons in a row into the UIScrollView, each of them has a title that is your page's title. When you tap a button ( you can get this event by UIButton's -addTarget:action:forControlEvents:), you can scroll the tapped button to the right position, highlight it, and put a little triangle below it.
There are many possibilities. Say, you can replace the buttons with UILabel and add UITapGestureRecognizer to capture the users tap, or you can replace the UIScrollView with UITableView if you get a long list of pages(Of course that will introduce some complexity). You just need to pick your favorite and try it out.

这篇关于UIPage Control定制样式NatGeo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆