Skip to content

Commit

Permalink
Update progressView center using autolayout (thiagoperes#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiancheong committed Aug 27, 2018
1 parent d4ffb28 commit 47b2e05
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Classes/IDMZoomingScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,24 @@ - (id)initWithPhotoBrowser:(IDMPhotoBrowser *)browser {
[_photoImageView addInteraction:drag];
}

CGRect screenBound = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenBound.size.width;
CGFloat screenHeight = screenBound.size.height;

if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
screenWidth = screenBound.size.height;
screenHeight = screenBound.size.width;
}

// Progress view
_progressView = [[DACircularProgressView alloc] initWithFrame:CGRectMake((screenWidth-35.)/2., (screenHeight-35.)/2, 35.0f, 35.0f)];
_progressView = [[DACircularProgressView alloc] initWithFrame:CGRectZero];
_progressView.translatesAutoresizingMaskIntoConstraints = NO;
[_progressView setProgress:0.0f];
_progressView.tag = 101;
_progressView.thicknessRatio = 0.1;
_progressView.roundedCorners = NO;
_progressView.trackTintColor = browser.trackTintColor ? self.photoBrowser.trackTintColor : [UIColor colorWithWhite:0.2 alpha:1];
_progressView.progressTintColor = browser.progressTintColor ? self.photoBrowser.progressTintColor : [UIColor colorWithWhite:1.0 alpha:1];
[self addSubview:_progressView];


[_progressView addConstraint:[NSLayoutConstraint constraintWithItem:_progressView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35]];
[_progressView addConstraint:[NSLayoutConstraint constraintWithItem:_progressView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35]];

[self addConstraint:[NSLayoutConstraint constraintWithItem:_progressView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem:_progressView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0]];


// Setup
self.backgroundColor = [UIColor clearColor];
self.delegate = self;
Expand Down

0 comments on commit 47b2e05

Please sign in to comment.