forked from aydenp/Ultrasound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathABVolumeSliderKnob.m
42 lines (35 loc) · 1.07 KB
/
ABVolumeSliderKnob.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
//
// ABVolumeSliderKnob.m
// Ultrasound
//
// Created by Ayden Panhuyzen on 8/27/18.
// Copyright © 2018 Ayden Panhuyzen. All rights reserved.
//
#import "ABVolumeSliderKnob.h"
@implementation ABVolumeSliderKnob
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setupForDisplay];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.layer.cornerRadius = fmin(self.bounds.size.width, self.bounds.size.height) / 2;
}
- (void)setupForDisplay {
self.userInteractionEnabled = NO;
self.backgroundColor = [UIColor whiteColor];
self.layer.shadowRadius = 2;
self.layer.shadowOffset = CGSizeMake(0, 2);
self.layer.shadowOpacity = 0.2;
self.layer.shadowColor = [UIColor blackColor].CGColor;
[self.heightAnchor constraintEqualToConstant:10].active = YES;
[self.widthAnchor constraintEqualToAnchor:self.heightAnchor].active = YES;
}
- (void)setHasShadow:(BOOL)hasShadow {
_hasShadow = hasShadow;
self.layer.shadowOpacity = hasShadow ? 0.2 : 0;
}
@end