-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeTableDayView.m
74 lines (54 loc) · 2.07 KB
/
TimeTableDayView.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
//
// TimeTableDayView.m
// SmartCampus
//
// Created by LeeRowoon on 2015. 7. 20..
// Copyright (c) 2015년 TimeHUB. All rights reserved.
//
#import "TimeTableDayView.h"
@interface TimeTableDayView()
@property (strong, nonatomic) UIButton *dayButton;
@end
@implementation TimeTableDayView
- (BOOL)isOpaque {
return NO;
}
- (void)drawRect:(CGRect)rect {
self.backgroundColor = [UIColor whiteColor];
if (!self.timeTableDay) {
return;
}
if (!self.dayButton) {
// 요일 버튼
self.dayButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, DAY_CIRCLE_VIEW_WIDTH, DAY_CIRCLE_VIEW_HEIGHT)];
}
// 요일 버튼 가운데 배치
self.dayButton.center = CGPointMake(rect.size.width / 2, rect.size.height / 2);
// 폰트
UIFont *dayFont = [UIFont fontWithName:DAY_FONT_NAME size:DAY_FONT_SIZE];
// 폰트 색상
UIColor *dayFontColor;
// 속성
NSDictionary *attributes;
if (self.timeTableDay.isSelected) {
dayFontColor = [UIColor whiteColor];
attributes = @{
NSForegroundColorAttributeName : dayFontColor,
NSFontAttributeName : dayFont
};
// 요일 배경 변경 (Circle 모양)
self.dayButton.backgroundColor = [UIColor colorWithRed:0.153 green:0.509 blue:0.5857 alpha:1.0];
self.dayButton.layer.cornerRadius = self.dayButton.frame.size.width / 2;
} else {
dayFontColor = [UIColor colorWithRed:0.1569 green:0.5098 blue:0.5843 alpha:1.0];
attributes = @{
NSForegroundColorAttributeName : dayFontColor,
NSFontAttributeName : dayFont
};
}
NSString *dayTitle = [TimeTableDay dayToString:self.timeTableDay.day];
NSAttributedString *dayTitleAttr = [[NSAttributedString alloc] initWithString:dayTitle attributes:attributes];
[self.dayButton setAttributedTitle:dayTitleAttr forState:UIControlStateNormal];
[self addSubview:self.dayButton];
}
@end