This repository has been archived by the owner on Mar 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIView+layout.h
55 lines (44 loc) · 1.74 KB
/
UIView+layout.h
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
//
// UIView+PLKAdditions.h
// Plank Multimedia Inc.
//
// Created by Sean Fraser on 2013-08-28.
// http://www.plankdesign.com/blog/2013/08/making-uiviews-friendlier/
// Copyright (c) 2013 Plank Multimedia Inc. All rights reserved.
//
typedef enum{
PLKViewAlignmentTopLeft,
PLKViewAlignmentTopCenter,
PLKViewAlignmentTopRight,
PLKViewAlignmentMiddleLeft,
PLKViewAlignmentCenter,
PLKViewAlignmentMiddleRight,
PLKViewAlignmentBottomLeft,
PLKViewAlignmentBottomCenter,
PLKViewAlignmentBottomRight,
} PLKViewAlignment;
@interface UIView (layout)
//-----------------------------
#pragma mark - View Positioning
//-----------------------------
//access frame fields individually
@property (nonatomic) CGFloat viewWidth; //view.frame.size.width
@property (nonatomic) CGFloat viewHeight; //view.frame.size.height
@property (nonatomic) CGFloat viewX; //view.frame.origin.x
@property (nonatomic) CGFloat viewY; //view.frame.origin.y
@property (nonatomic) CGPoint viewOrigin; //view.frame.origin
@property (nonatomic) CGSize viewSize; //view.frame.size
@property (nonatomic) CGFloat viewRightEdge; //view.frame.origin.x + view.frame.size.width
@property (nonatomic) CGFloat viewBottomEdge; //view.frame.origin.y + view.frame.size.height
//get the point at the center of the view's bounds
- (CGPoint) boundsCenter;
//round frame coordinates to nearest integer
- (void) frameIntegral;
//-------------------------
#pragma mark View Alignment
//-------------------------
//align the view relative to a point. Place the specified edge at the point
-(void)align:(PLKViewAlignment)alignment relativeToPoint:(CGPoint)point;
//align the view relative to a rectangle
-(void)align:(PLKViewAlignment)alignment relativeToRect:(CGRect)rect;
@end