Skip to content

Commit

Permalink
Update DLTiledImageView.m
Browse files Browse the repository at this point in the history
  • Loading branch information
darling0825 authored Dec 19, 2017
1 parent 0031d27 commit 05b4110
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions DLPhotoPicker/View/TiledImageView/DLTiledImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,24 @@ - (void)setImage:(UIImage *)image {
- (void)drawRect:(CGRect)rect {
if (self.image) {

dispatch_async(dispatch_get_main_queue(), ^{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
__block CGRect rect = CGRectZero;
if (![NSThread isMainThread]) {
dispatch_sync(dispatch_get_main_queue(), ^{
rect = self.bounds;
});
}else {
rect = self.bounds;
}

CGRect rect = self.bounds;

CGContextTranslateCTM(ctx, rect.origin.x, rect.origin.y);
CGContextTranslateCTM(ctx, 0.0, rect.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextTranslateCTM(ctx, -rect.origin.x, -rect.origin.y);
CGContextDrawImage(ctx, rect, self.image.CGImage);
CGContextRestoreGState(ctx);
});
//
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGContextTranslateCTM(ctx, rect.origin.x, rect.origin.y);
CGContextTranslateCTM(ctx, 0.0, rect.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextTranslateCTM(ctx, -rect.origin.x, -rect.origin.y);
CGContextDrawImage(ctx, rect, self.image.CGImage);
CGContextRestoreGState(ctx);
}
}

Expand Down

0 comments on commit 05b4110

Please sign in to comment.