forked from nsomar/OAStackView
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOAStackView.h
More file actions
111 lines (89 loc) · 3.7 KB
/
OAStackView.h
File metadata and controls
111 lines (89 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
// OAStackView.h
// OAStackView
//
// Created by Omar Abdelhafith on 14/06/2015.
// Copyright © 2015 Omar Abdelhafith. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, OAStackViewDistribution) {
/* When items do not fit (overflow) or fill (underflow) the space available
adjustments occur according to compressionResistance or hugging
priorities of items, or when that is ambiguous, according to arrangement
order.
*/
OAStackViewDistributionFill = 0,
/* Items are all the same size.
When space allows, this will be the size of the item with the largest
intrinsicContentSize (along the axis of the stack).
Overflow or underflow adjustments are distributed equally among the items.
*/
OAStackViewDistributionFillEqually,
/* Overflow or underflow adjustments are distributed among the items proportional
to their intrinsicContentSizes.
*/
OAStackViewDistributionFillProportionally,
/* Additional underflow spacing is divided equally in the spaces between the items.
Overflow squeezing is controlled by compressionResistance priorities followed by
arrangement order.
*/
OAStackViewDistributionEqualSpacing,
/* Equal center-to-center spacing of the items is maintained as much
as possible while still maintaining a minimum edge-to-edge spacing within the
allowed area.
Additional underflow spacing is divided equally in the spacing. Overflow
squeezing is distributed first according to compressionResistance priorities
of items, then according to subview order while maintaining the configured
(edge-to-edge) spacing as a minimum.
*/
OAStackViewDistributionEqualCentering,
};
typedef NS_ENUM(NSInteger, OAStackViewAlignment) {
OAStackViewAlignmentFill,
/* Align the leading edges of vertically stacked items
or the top edges of horizontally stacked items tightly to the relevant edge
of the container
*/
OAStackViewAlignmentLeading,
OAStackViewAlignmentTop = OAStackViewAlignmentLeading,
OAStackViewAlignmentFirstBaseline NS_ENUM_AVAILABLE_IOS(8_0), // Valid for horizontal axis only
/* Center the items in a vertical stack horizontally
or the items in a horizontal stack vertically
*/
OAStackViewAlignmentCenter,
/* Align the trailing edges of vertically stacked items
or the bottom edges of horizontally stacked items tightly to the relevant
edge of the container
*/
OAStackViewAlignmentTrailing,
OAStackViewAlignmentBottom = OAStackViewAlignmentTrailing,
OAStackViewAlignmentBaseline,
OAStackViewAlignmentLastBaseline = OAStackViewAlignmentBaseline, // Valid for horizontal axis only
};
// Keep older versions of the compiler happy
#ifndef NS_ASSUME_NONNULL_BEGIN
#define NS_ASSUME_NONNULL_BEGIN
#define NS_ASSUME_NONNULL_END
#define nullable
#define nonnullable
#define __nullable
#endif
NS_ASSUME_NONNULL_BEGIN
@interface OAStackView : UIView
@property(nonatomic,readonly,copy) NSArray *arrangedSubviews;
//Default is Vertical
@property(nonatomic) UILayoutConstraintAxis axis;
@property(nonatomic) IBInspectable NSInteger axisValue;
@property(nonatomic) IBInspectable CGFloat spacing;
//Default is Fill
@property(nonatomic) OAStackViewAlignment alignment;
@property(nonatomic) IBInspectable NSInteger alignmentValue;
@property(nonatomic) OAStackViewDistribution distribution;
@property(nonatomic) IBInspectable NSInteger distributionValue;
- (instancetype)initWithArrangedSubviews:(NSArray*)views NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
- (void)addArrangedSubview:(UIView *)view;
- (void)removeArrangedSubview:(UIView *)view;
- (void)insertArrangedSubview:(UIView *)view atIndex:(NSUInteger)stackIndex;
@end
NS_ASSUME_NONNULL_END