Latest 1.2.0
Homepage https://github.com/silencedev/PPNeon
License MIT
Platforms ios 6.0, requires ARC
Frameworks UIKit
Authors

PPNeon来自于Swift框架 Neon

License Badge w/ Version
CocoaPods

PPNeon是基于Frame建立的,PPNeon不是自动布局,他是方便使用和维护的高性能布局框架。

使用Cocoapods安装

你可以使用 Cocoapods 安装 PPNeon,在 Podfile文件中添加:

pod 'PPNeon'

Demo

demo

5种布局方式

layout

Frame

链式布局

Anchoring

Anchoring是一种基于父视图的布局方式。

Center
Filling SuperView
Corner
Edge
Filling Edge

Anchoring Center & Filling SuperView

- (void)anchorInCenter:(CGFloat)width height:(CGFloat)height;

- (void)fillSuperview:(CGFloat)left right:(CGFloat)right top:(CGFloat)top bottom:(CGFloat)bottom;

anchorcenter

Anchoring Corner

corner布局方式:

corner

- (void)anchorInCorner:(PPCorner)corner xPad:(CGFloat)xPad yPad:(CGFloat)yPad width:(CGFloat)width height:(CGFloat)height;

corner1

Anchoring Edge

edge布局方式:

edge

- (void)anchorToEdge:(PPEdge)edge padding:(CGFloat)padding width:(CGFloat)width height:(CGFloat)height;

edge1

Anchoring Filling Edge

- (void)anchorAndFillEdge:(PPEdge)edge xPad:(CGFloat)xPad yPad:(CGFloat)yPad otherSize:(CGFloat)otherSize;

edge2

Filling Edge宽度计算方式:self.superView.width – 2 xPad
Filling Edge高度计算方式:self.superView.height – 2
yPad

Align

Align是一种基于兄弟视图之间的相对布局方式。
Align有12种布局类型,提供了3种布局大类。

Align
Align Filling(Filling Width & Filling Height)
Align Between(Vertical & Horizontal)

aligntype

Align

- (void)align:(PPAlign)align relativeTo:(PPNeon_View *)sibling padding:(CGFloat)padding width:(CGFloat)width height:(CGFloat)height offset:(CGFloat)offset;

align

Align Filling

- (void)alignAndFillWidth:(PPAlign)align relativeTo:(PPNeon_View *)sibling padding:(CGFloat)padding height:(CGFloat)height offset:(CGFloat)offset;

alignfw

Align Filling 宽度计算方式:self.superView.width – sibling.xMax – 2 * padding

- (void)alignAndFillHeight:(PPAlign)align relativeTo:(PPNeon_View *)sibling padding:(CGFloat)padding width:(CGFloat)width offset:(CGFloat)offset;

alignfh

Align Filling 高度计算方式:self.superView.height – sibling.y – 2 * padding

- (void)alignAndFill:(PPAlign)align relativeTo:(PPNeon_View *)sibling padding:(CGFloat)padding offset:(CGFloat)offset;

alignf

Align Filling 宽度计算方式:self.superView.width – sibling.xMax – 2 padding
Align Filling 高度计算方式:self.superView.Height – 2
padding

Align Between

- (void)alignBetweenHorizontal:(PPAlign)align primaryView:(PPNeon_View *)primaryView secondaryView:(PPNeon_View *)secondaryView padding:(CGFloat)padding height:(CGFloat)height offset:(CGFloat)offset;

alignbetweenh

Align Between 宽度计算方式:secondaryView.x – primaryView.xMax – 2 * padding

- (void)alignBetweenVertical:(PPAlign)align primaryView:(PPNeon_View *)primaryView secondaryView:(PPNeon_View *)secondaryView padding:(CGFloat)padding width:(CGFloat)width offset:(CGFloat)offset;

alignbetweenv

Align Between 高度计算方式:secondaryView.y – primaryView.yMax – 2 * padding

Group

Group是一种基于兄弟视图之间的分组布局方式。
Group布局分为Horizontal和Vertical两种方式。

Fill Group
Corner Group
Edge Group
Align Group

Fill Group

- (void)groupInCenter:(PPGroup)group views:(NSArray *)views padding:(CGFloat)padding width:(CGFloat)width height:(CGFloat)height;

groupcenter

- (void)groupAndFill:(PPGroup)group views:(NSArray *)views padding:(CGFloat)padding;

groupfill

- (void)groupAndFill:(PPGroup)group views:(NSArray *)views padding:(CGFloat)padding width:(CGFloat)width height:(CGFloat)height;

groupfill2

Corner Group

- (void)groupInCorner:(PPGroup)group views:(NSArray *)views inCorner:(PPCorner)corner padding:(CGFloat)padding width:(CGFloat)width height:(CGFloat)height;

groupcorner

Edge Group

- (void)groupAgainstEdge:(PPGroup)group views:(NSArray *)views againstEdge:(PPEdge)edge padding:(CGFloat)padding width:(CGFloat)width height:(CGFloat)height;

groupedge

Align Group

- (void)groupAndAlign:(PPGroup)group andAlign:(PPAlign)align viwes:(NSArray *)views relativeTo:(PPNeon_View *)sibling padding:(CGFloat)padding width:(CGFloat)width height:(CGFloat)height;

groupalign

性能比较

这里比较的是Masonry,Masonry用的是AutoLayout,性能自然会低一些。

benchmark

Latest podspec

{
    "name": "PPNeon",
    "summary": "High performance layout framework for iOS.",
    "version": "1.2.0",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "silencedev": "[email protected]"
    },
    "social_media_url": "https://silencedev.github.io",
    "homepage": "https://github.com/silencedev/PPNeon",
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/silencedev/PPNeon.git",
        "tag": "1.2.0"
    },
    "requires_arc": true,
    "source_files": "PPNeon/**/*.{h,m}",
    "public_header_files": "PPNeon/**/*.{h}",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This