-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewController.m
83 lines (64 loc) · 3.55 KB
/
ViewController.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// ViewController.m
// DitkoDemo-tvOS
//
// Created by William Towe on 3/8/17.
// Copyright © 2021 Kosoku Interactive, LLC. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import "ViewController.h"
#import <Ditko/Ditko.h>
@interface ViewController ()
@end
@implementation ViewController
- (NSString *)title {
return @"Controls";
}
- (void)loadView {
KDIView *view = [[KDIView alloc] initWithFrame:CGRectZero];
[view setBackgroundColor:KDIColorRandomRGB()];
[view setBorderColor:KDIColorRandomRGB()];
[view setBorderWidth:4.0];
[view setBorderOptions:KDIBorderOptionsAll];
[view setBorderEdgeInsets:UIEdgeInsetsMake(8.0, 8.0, 8.0, 8.0)];
[self setView:view];
}
- (void)viewDidLoad {
[super viewDidLoad];
KDIGradientView *gradientView = [[KDIGradientView alloc] initWithFrame:CGRectZero];
[gradientView setColors:@[KDIColorRandomRGB(),KDIColorRandomRGB()]];
[gradientView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:gradientView];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-margin-[view]-margin-|" options:0 metrics:@{@"margin": @16.0} views:@{@"view": gradientView}]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-margin-[view]-margin-|" options:0 metrics:@{@"margin": @16.0} views:@{@"view": gradientView}]];
KDIBadgeView *badgeView = [[KDIBadgeView alloc] initWithFrame:CGRectZero];
[badgeView setBadgeFont:[UIFont boldSystemFontOfSize:32.0]];
[badgeView setBadge:@"1234"];
[badgeView setTranslatesAutoresizingMaskIntoConstraints:NO];
[gradientView addSubview:badgeView];
[gradientView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[view]" options:0 metrics:nil views:@{@"view": badgeView}]];
[gradientView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[view]" options:0 metrics:nil views:@{@"view": badgeView}]];
KDIButton *button = [[KDIButton alloc] initWithFrame:CGRectZero];
[button setTranslatesAutoresizingMaskIntoConstraints:NO];
[button setTitleColor:KDIColorRandomRGB() forState:UIControlStateNormal];
[button setTitle:@"Title" forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"button_image"] forState:UIControlStateNormal];
[button setTitleContentHorizontalAlignment:KDIButtonContentHorizontalAlignmentLeft];
[button setTitleContentVerticalAlignment:KDIButtonContentVerticalAlignmentCenter];
[button setImageContentHorizontalAlignment:KDIButtonContentHorizontalAlignmentRight];
[button setImageContentVerticalAlignment:KDIButtonContentVerticalAlignmentCenter];
[gradientView addSubview:button];
[gradientView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[subview]-[view]" options:0 metrics:nil views:@{@"view": button, @"subview": badgeView}]];
[gradientView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[view]" options:0 metrics:nil views:@{@"view": button}]];
}
@end