123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #import <PureLayout/PureLayout.h>
- #import "CTAssetsPickerDefines.h"
- #import "CTAssetsPageView.h"
- @interface CTAssetsPageView ()
- @property (nonatomic, assign) BOOL didSetupConstraints;
- @end
- @implementation CTAssetsPageView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- if (self = [super initWithFrame:frame])
- {
- _pageBackgroundColor = CTAssetsPageViewPageBackgroundColor;
- _fullscreenBackgroundColor = CTAssetsPageViewFullscreenBackgroundColor;
- [self setupViews];
- }
-
- return self;
- }
- #pragma mark - Setup
- - (void)setupViews
- {
- self.backgroundColor = self.pageBackgroundColor;
- }
- #pragma mark - Apperance
- - (void)setPageBackgroundColor:(UIColor *)backgroundColor
- {
- UIColor *color = (backgroundColor) ? backgroundColor : CTAssetsPageViewPageBackgroundColor;
- _pageBackgroundColor = color;
- self.backgroundColor = color;
- }
- - (void)setFullscreenBackgroundColor:(UIColor *)fullscreenBackgroundColor
- {
- UIColor *color = (fullscreenBackgroundColor) ? fullscreenBackgroundColor : CTAssetsPageViewFullscreenBackgroundColor;
- _fullscreenBackgroundColor = color;
- }
- #pragma mark - Update auto layout constraints
- - (void)updateConstraints
- {
- if (!self.didSetupConstraints)
- {
- [self autoPinEdgesToSuperviewEdges];
- self.didSetupConstraints = YES;
- }
-
- [super updateConstraints];
- }
- #pragma mark - Fading views
- - (void)enterFullscreen
- {
- [UIView animateWithDuration:0.2
- animations:^{
- self.backgroundColor = self.fullscreenBackgroundColor;
- }];
- }
- - (void)exitFullscreen
- {
- [UIView animateWithDuration:0.2
- animations:^{
- self.backgroundColor = self.pageBackgroundColor;
- }];
- }
- @end
|