-
Notifications
You must be signed in to change notification settings - Fork 0
/
View2.m
66 lines (52 loc) · 1.37 KB
/
View2.m
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
//
// View2.m
// AutolayoutTesting
//
// Created by Agathe Battestini on 3/28/13.
// Copyright (c) 2013. All rights reserved.
//
#import "View2.h"
@implementation View2
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initialize];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
[self initialize];
}
return self;
}
- (void)awakeFromNib
{
[self initialize];
}
- (void)initialize
{
// Initialization code
self.numberOfLines = 1;
[self setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisVertical];
[self setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
[self setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisVertical];
[self setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
}
- (void)setNumberOfLines:(NSInteger)numberOfLines
{
_numberOfLines = numberOfLines;
[self invalidateIntrinsicContentSize];
}
- (CGSize)intrinsicContentSize
{
return CGSizeMake(UIViewNoIntrinsicMetric, 44.0 * self.numberOfLines);
}
- (UIEdgeInsets)alignmentRectInsets
{
return UIEdgeInsetsMake(4.0, 4.0, 4.0, 4.0);
}
@end