测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年3月 |
SwiftSwift版本 | 3.0 |
SPM支持SPM | ✗ |
由Miran Brajsa维护。
此包包含我们在许多项目中重复使用的Swift UI组件(我们是一支由Five Agency的iOS团队组成)。我们预计将添加更多组件,但在那时,您可以自由地使用/重新使用/升级此处现有的所有代码。有关动画器、自定义视图、布局和其他好用的代码片段,一切都有。试试吧!
没有其他依赖项。
当前支持的安装选项
$ git submodule add https://github.com/fiveagency/ios-five-ui-components.git
将FiveUIComponents.xcodeproj
拖入到项目导航器中。
转到项目 > 目标 > 构建阶段 > 链接到二进制文件库
,点击+
并选择FiveUIComponents.framework
目标。
要运行示例项目,请执行以下操作。
$ git clone https://github.com/fiveagency/ios-five-ui-components.git YOUR_DESTINATION_FOLDER
FiveUIComponents.xcworkspace
,选择示例
方案并按运行
。此方法将构建所有内容并运行示例应用。/**
Color at the start of the gradient.
*/
@IBInspectable public var startColor: UIColor
/**
Color at the end of the gradient.
*/
@IBInspectable public var endColor: UIColor
/**
Start point for gradient vector in normalized coordinates.
*/
@IBInspectable public var startPoint: UIColor
/**
End point for gradient vector in normalized coordinates.
*/
@IBInspectable public var endPoint: UIColor
示例用法
/**
Number of page indicators.
*/
@IBInspectable public var numberOfPages: Int
/**
Spacing between page indicators.
*/
@IBInspectable public var pageIndicatorSpacing: CGFloat
/**
Radius of page indicators that do not represent the current page.
*/
@IBInspectable public var pageIndicatorRadius: CGFloat
/**
Color of page indicators that do not represent the current page.
*/
@IBInspectable 公共变量 pageIndicatorColor: UIColor
/**
Index of the page indicator that is highlighted.
If this number if not an integer, size and color of two neighboring indicators
are interpolated accordingly to represent the page.
*/
@IBInspectable 公共变量 currentPage: CGFloat
/**
Radius of page indicator that represents the current page.
*/
@IBInspectable 公共变量 currentPageIndicatorRadius: CGFloat
/**
Color of page indicator that represents the current page.
*/
@IBInspectable 公共变量 currentPageIndicatorColor: UIColor
/**
Duration of the animation that updates the current page once the control was tapped.
*/
public var animationDuration:TimeInterval
示例用法
let frame = CGRect(x: 0, y: 0, width: 200, height: 50) let pageControl = SmoothPageControl(frame: frame) pageControl.numberOfPages = 5 // now tap the control |
/**
Creates the animator with custom animation.
- parameter collectionView: Collection view that needs to be animated.
- parameter setupInitialCellState: Block that sets up the cell before it is animated.
- parameter setupFinalCellState: Block that sets up the final state for the cell. This block is animated.
*/
public init(collectionView: UICollectionView, setupInitialCellState: @escaping SetupDelayedCellClosure, setupFinalCellState: @escaping SetupDelayedCellClosure)
/**
Creates the animator with one of the default animations.
- parameter collectionView: Collection view which needs to be animated.
- parameter animation: The animation to perfom on the cell.
*/
public convenience init(collectionView: UICollectionView, animation: DelayedCellAnimation)
/**
Duration of the animation for individual cell.
*/
public var animationDuration:TimeInterval
/**
Delay between animations of individual cells.
*/
public var nextCellAnimationDelay: TimeInterval
/**
Animates individual cell.
- parameter cell: Cell to animate.
- parameter indexPath: Index path of the cell.
*/
public func animate(_ cell: UICollectionViewCell, at indexPath: IndexPath)
/**
Invalidates the animator. Call this before reloading the collection view.
*/
public func invalidate()
示例用法
/**
The margins used to lay out content in a section.
*/
public var sectionInset: UIEdgeInsets
/**
The size to use for cells.
*/
public var itemSize: CGSize
DynamicSpacingCollectionViewLayout 有额外的属性
/**
The translation amount that will be added to the leading cell of a section.
*/
public var expansion: CGFloat
/**
The factor by which translation of the next cell in section is multiplied, starting from the leading cell.
*/
public var nextCellExpansionFactor: CGFloat
示例用法
/**
The value indicating how fast will the collection view be scrolled.
*/
public var scrollSensitivity: CGFloat
/**
The layout used to organize the collection view’s items.
*/
public var collectionViewLayout: SnappableCollectionViewLayout
public protocol SnappableCollectionViewLayout
/**
Calculates snapped content offset for given offset inside content view.
- parameter offset: The point in the content view.
*/
func snappedContentOffset(for offset: CGPoint) -> CGPoint
public class CenteredCellCollectionViewLayout: SnappableCollectionViewLayout
/**
The size to use for cells.
*/
public var itemSize: CGSize
/**
Layout attributes for cell in the center.
*/
public var cellAttributesInCenter: CenteredCellCollectionViewLayoutAttributes
/**
Layout attributes for cell on an edge.
*/
public var cellAttributesOnEdge: CenteredCellCollectionViewLayoutAttributes
public class CenteredCellCollectionViewLayoutAttributes
/**
The scale of the item.
*/
public var scale: CGFloat
/**
The rotation angle of the item expressed in radians.
*/
public var rotationAngle: CGFloat
/**
The transparency of the item. Possible values are between 0.0 (transparent) and 1.0 (opaque).
*/
public var alpha: CGFloat
示例用法
/**
Titles of buttons.
Size of array determines how many buttons will be present.
*/
public var titles: [String]!
/**
Integer index of selected button.
*/
public var currentIndex: Int = 0
/**
Relative index.
It is used for updating underline indicator and interpolation of buttons' colors.
*/
public var currentRelativeIndex: CGFloat = 0
/**
Visual appearance of buttons.
Use PageTitlesAppearance struct.
*/
public var appearance: PageTitlesAppearance
public struct PageTitlesAppearance
/**
Visual appearance of buttons.
*/
public struct PageTitlesAppearance {
public var activeTitleColor: UIColor
public var inactiveTitleColor: UIColor
public var indicatorColor: UIColor
public var indicatorHeight: CGFloat
public var font: UIFont
}
public protocol PageTitlesControlDelegate
/**
Used to inform delegate of PageTitlesControl about index of selected button.
*/
func pageTitlesControl(_ pageTitlesControl: PageTitlesControl, didSelectButtonAtIndex index: Int)
示例用法
@IBOutlet public weak var datasource: PageViewControllerDatasource?
@IBOutlet public weak var pageControlDelegate: PageControlDelegate?
public protocol PageViewControllerDatasource
/**
Datasource.
*/
func viewControllers(for pageViewController: PageViewController) -> [UIViewController]
public protocol PageControlDelegate
/**
Provides information about current relative index so that delegate can update page control.
*/
func updatePageControlsRelativeIndex(_ relativeIndex: CGFloat)
func updatePageControlsIndex(from relativeIndex: CGFloat)
例子
It is best used in combination with PageTitlesControl or SmoothPageControl. |
五个 UI 组件库团队(按字母顺序排列)
Denis Mendica
Ivan Vranjić
Mario Radonić
Miran Brajša
Niko Mikuličić
FiveUIComponents 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。