mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
472dbd21b1
commit
4219af01e7
@ -1,12 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_cam_flashoff (1).pdf",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,12 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ic_cam_flashon.pdf",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Binary file not shown.
@ -26,7 +26,7 @@ static NSString *TGCameraEncodeText(NSString *string, int key)
|
||||
|
||||
+ (UIColor *)accentColor
|
||||
{
|
||||
return UIColorRGB(0xffd60a);
|
||||
return UIColorRGB(0xf8d74a);
|
||||
}
|
||||
|
||||
+ (UIColor *)redColor
|
||||
|
@ -198,6 +198,45 @@
|
||||
_topPanelBackgroundView.backgroundColor = [TGCameraInterfaceAssets transparentPanelBackgroundColor];
|
||||
[_topPanelView addSubview:_topPanelBackgroundView];
|
||||
|
||||
_zoomModeView = [[TGCameraZoomModeView alloc] initWithFrame:CGRectMake(floor((frame.size.width - 129.0) / 2.0), frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 18 - 43, 129, 43) hasUltrawideCamera:hasUltrawideCamera hasTelephotoCamera:hasTelephotoCamera minZoomLevel:hasUltrawideCamera ? 0.5 : 1.0 maxZoomLevel:8.0];
|
||||
_zoomModeView.zoomChanged = ^(CGFloat zoomLevel, bool done, bool animated) {
|
||||
__strong TGCameraMainPhoneView *strongSelf = weakSelf;
|
||||
if (strongSelf == nil)
|
||||
return;
|
||||
|
||||
if (done) {
|
||||
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel];
|
||||
[strongSelf->_zoomModeView setZoomLevel:zoomLevel animated:false];
|
||||
|
||||
if (!strongSelf->_zoomWheelView.isHidden) {
|
||||
strongSelf->_dismissingWheel = true;
|
||||
|
||||
TGDispatchAfter(0.6, dispatch_get_main_queue(), ^{
|
||||
if (strongSelf->_dismissingWheel) {
|
||||
[strongSelf->_zoomModeView setHidden:false animated:true];
|
||||
[strongSelf->_zoomWheelView setHidden:true animated:true];
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
strongSelf->_dismissingWheel = false;
|
||||
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel];
|
||||
[strongSelf->_zoomModeView setHidden:true animated:true];
|
||||
[strongSelf->_zoomWheelView setHidden:false animated:true];
|
||||
}
|
||||
|
||||
if (strongSelf.zoomChanged != nil)
|
||||
strongSelf.zoomChanged(zoomLevel, animated);
|
||||
};
|
||||
[_zoomModeView setZoomLevel:1.0];
|
||||
[self addSubview:_zoomModeView];
|
||||
|
||||
_zoomWheelView = [[TGCameraZoomWheelView alloc] initWithFrame:CGRectMake(0.0, frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 132, frame.size.width, 132) hasUltrawideCamera:hasUltrawideCamera hasTelephotoCamera:hasTelephotoCamera];
|
||||
[_zoomWheelView setHidden:true animated:false];
|
||||
[_zoomWheelView setZoomLevel:1.0];
|
||||
_zoomWheelView.userInteractionEnabled = false;
|
||||
[self addSubview:_zoomWheelView];
|
||||
|
||||
_bottomPanelView = [[UIView alloc] init];
|
||||
[self addSubview:_bottomPanelView];
|
||||
|
||||
@ -263,45 +302,6 @@
|
||||
_toastView.userInteractionEnabled = false;
|
||||
[self addSubview:_toastView];
|
||||
|
||||
_zoomModeView = [[TGCameraZoomModeView alloc] initWithFrame:CGRectMake(floor((frame.size.width - 129.0) / 2.0), frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 18 - 43, 129, 43) hasUltrawideCamera:hasUltrawideCamera hasTelephotoCamera:hasTelephotoCamera minZoomLevel:hasUltrawideCamera ? 0.5 : 1.0 maxZoomLevel:8.0];
|
||||
_zoomModeView.zoomChanged = ^(CGFloat zoomLevel, bool done, bool animated) {
|
||||
__strong TGCameraMainPhoneView *strongSelf = weakSelf;
|
||||
if (strongSelf == nil)
|
||||
return;
|
||||
|
||||
if (done) {
|
||||
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel];
|
||||
[strongSelf->_zoomModeView setZoomLevel:zoomLevel animated:false];
|
||||
|
||||
if (!strongSelf->_zoomWheelView.isHidden) {
|
||||
strongSelf->_dismissingWheel = true;
|
||||
|
||||
TGDispatchAfter(0.6, dispatch_get_main_queue(), ^{
|
||||
if (strongSelf->_dismissingWheel) {
|
||||
[strongSelf->_zoomModeView setHidden:false animated:true];
|
||||
// [strongSelf->_zoomWheelView setHidden:true animated:true];
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
strongSelf->_dismissingWheel = false;
|
||||
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel];
|
||||
[strongSelf->_zoomModeView setHidden:true animated:true];
|
||||
// [strongSelf->_zoomWheelView setHidden:false animated:true];
|
||||
}
|
||||
|
||||
if (strongSelf.zoomChanged != nil)
|
||||
strongSelf.zoomChanged(zoomLevel, animated);
|
||||
};
|
||||
[_zoomModeView setZoomLevel:1.0];
|
||||
[self addSubview:_zoomModeView];
|
||||
|
||||
_zoomWheelView = [[TGCameraZoomWheelView alloc] initWithFrame:CGRectMake(0.0, frame.size.height - _bottomPanelHeight - _bottomPanelOffset - 132, frame.size.width, 132) hasUltrawideCamera:hasUltrawideCamera hasTelephotoCamera:hasTelephotoCamera];
|
||||
[_zoomWheelView setHidden:true animated:false];
|
||||
[_zoomWheelView setZoomLevel:1.0];
|
||||
_zoomWheelView.userInteractionEnabled = false;
|
||||
[self addSubview:_zoomWheelView];
|
||||
|
||||
_flashControl.modeChanged = ^(PGCameraFlashMode mode)
|
||||
{
|
||||
__strong TGCameraMainPhoneView *strongSelf = weakSelf;
|
||||
|
@ -196,6 +196,7 @@
|
||||
|
||||
_label = [[UILabel alloc] initWithFrame:self.bounds];
|
||||
_label.textAlignment = NSTextAlignmentCenter;
|
||||
_label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
|
||||
[self addSubview:_backgroundView];
|
||||
[self addSubview:_label];
|
||||
@ -209,7 +210,6 @@
|
||||
|
||||
_label.text = value;
|
||||
_label.textColor = selected ? [TGCameraInterfaceAssets accentColor] : [UIColor whiteColor];
|
||||
_label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
|
||||
if (animated) {
|
||||
[UIView animateWithDuration:0.3f animations:^
|
||||
@ -225,7 +225,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface TGCameraZoomModeView ()
|
||||
@interface TGCameraZoomModeView () <UIGestureRecognizerDelegate>
|
||||
{
|
||||
CGFloat _minZoomLevel;
|
||||
CGFloat _maxZoomLevel;
|
||||
@ -276,14 +276,24 @@
|
||||
}
|
||||
|
||||
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
|
||||
panGestureRecognizer.delegate = self;
|
||||
[self addGestureRecognizer:panGestureRecognizer];
|
||||
|
||||
UILongPressGestureRecognizer *pressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(pressGesture:)];
|
||||
pressGestureRecognizer.delegate = self;
|
||||
[self addGestureRecognizer:pressGestureRecognizer];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
||||
if (gestureRecognizer.view == self && otherGestureRecognizer.view == self) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pressGesture:(UILongPressGestureRecognizer *)gestureRecognizer {
|
||||
switch (gestureRecognizer.state) {
|
||||
case UIGestureRecognizerStateBegan:
|
||||
@ -305,8 +315,14 @@
|
||||
|
||||
switch (gestureRecognizer.state) {
|
||||
case UIGestureRecognizerStateChanged:
|
||||
_zoomLevel = MAX(0.5, MIN(10.0, _zoomLevel - translation.x / 100.0));
|
||||
{
|
||||
CGFloat delta = -translation.x / 100.0;
|
||||
if (_zoomLevel > 2.0) {
|
||||
delta *= 2.0;
|
||||
}
|
||||
_zoomLevel = MAX(0.5, MIN(10.0, _zoomLevel + delta));
|
||||
self.zoomChanged(_zoomLevel, false, false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -363,15 +379,19 @@
|
||||
[_rightItem setValue:@"2" selected:false animated:animated];
|
||||
} else {
|
||||
[_leftItem setValue:@"0,5" selected:false animated:animated];
|
||||
[_centerItem setValue:@"1" selected:false animated:animated];
|
||||
|
||||
|
||||
CGFloat near = round(zoomLevel);
|
||||
if (ABS(zoomLevel - near) < 0.1) {
|
||||
[_rightItem setValue:[NSString stringWithFormat:@"%dx", (int)zoomLevel] selected:true animated:animated];
|
||||
NSString *value;
|
||||
if (ABS(zoomLevel - near) < 0.05) {
|
||||
value = [NSString stringWithFormat:@"%dx", (int)zoomLevel];
|
||||
} else {
|
||||
NSString *value = [NSString stringWithFormat:@"%.1fx", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
value = [[NSString stringWithFormat:@"%.1fx", zoomLevel] stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
}
|
||||
if (_rightItem.superview != nil) {
|
||||
[_centerItem setValue:@"1" selected:false animated:animated];
|
||||
[_rightItem setValue:value selected:true animated:animated];
|
||||
} else {
|
||||
[_centerItem setValue:value selected:true animated:animated];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -437,7 +457,17 @@
|
||||
{
|
||||
bool _hasUltrawideCamera;
|
||||
bool _hasTelephotoCamera;
|
||||
UIView *_containerView;
|
||||
UIImageView *_backgroundView;
|
||||
UIImageView *_scaleView;
|
||||
UIImageView *_maskView;
|
||||
UIImageView *_arrowView;
|
||||
|
||||
UILabel *_valueLabel;
|
||||
UILabel *_05Label;
|
||||
UILabel *_1Label;
|
||||
UILabel *_2Label;
|
||||
UILabel *_8Label;
|
||||
}
|
||||
@end
|
||||
|
||||
@ -459,63 +489,254 @@
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
- (NSArray *)ultraLines {
|
||||
return @[
|
||||
@[@0.5, @-19.6, @3],
|
||||
@[@0.6, @-14.4, @1],
|
||||
@[@0.7, @-10.0, @1],
|
||||
@[@0.8, @-6.3, @1],
|
||||
@[@0.9, @-3.0, @1]
|
||||
];
|
||||
}
|
||||
|
||||
- (NSArray *)lines {
|
||||
return @[
|
||||
@[@1.0, @0.0, @3],
|
||||
|
||||
@[@1.1, @2.7, @1],
|
||||
@[@1.2, @5.2, @1],
|
||||
@[@1.3, @7.4, @1],
|
||||
@[@1.4, @9.6, @1],
|
||||
@[@1.5, @11.5, @1],
|
||||
@[@1.6, @13.3, @1],
|
||||
@[@1.7, @15.0, @1],
|
||||
@[@1.8, @16.7, @1],
|
||||
@[@1.9, @18.2, @1],
|
||||
@[@2.0, @19.6, _hasTelephotoCamera ? @3 : @2],
|
||||
|
||||
@[@2.1, @21.0, @1],
|
||||
@[@2.2, @22.4, @1],
|
||||
@[@2.3, @23.7, @1],
|
||||
@[@2.4, @24.8, @1],
|
||||
@[@2.5, @26.0, @1],
|
||||
@[@2.6, @27.1, @1],
|
||||
@[@2.7, @28.2, @1],
|
||||
@[@2.8, @29.2, @1],
|
||||
@[@2.9, @30.2, @1],
|
||||
@[@3.0, @31.1, @2],
|
||||
|
||||
@[@3.1, @32.0, @1],
|
||||
@[@3.2, @32.9, @1],
|
||||
@[@3.3, @33.8, @1],
|
||||
@[@3.4, @34.7, @1],
|
||||
@[@3.5, @35.5, @1],
|
||||
@[@3.6, @36.34, @1],
|
||||
@[@3.7, @37.1, @1],
|
||||
@[@3.8, @37.85, @1],
|
||||
@[@3.9, @38.55, @1],
|
||||
@[@4.0, @39.3, @2],
|
||||
|
||||
@[@4.1, @40.0, @1],
|
||||
@[@4.2, @40.77, @1],
|
||||
@[@4.3, @41.4, @1],
|
||||
@[@4.4, @42.05, @1],
|
||||
@[@4.5, @42.63, @1],
|
||||
@[@4.6, @43.3, @1],
|
||||
@[@4.7, @43.89, @1],
|
||||
@[@4.8, @44.42, @1],
|
||||
@[@4.9, @45.05, @1],
|
||||
@[@5.0, @45.6, @2],
|
||||
|
||||
@[@5.1, @46.17, @1],
|
||||
@[@5.2, @46.77, @1],
|
||||
@[@5.3, @47.31, @1],
|
||||
@[@5.4, @47.78, @1],
|
||||
@[@5.5, @48.34, @1],
|
||||
@[@5.6, @48.8, @1],
|
||||
@[@5.7, @49.31, @1],
|
||||
@[@5.8, @49.85, @1],
|
||||
@[@5.9, @50.3, @1],
|
||||
@[@6.0, @50.8, @2],
|
||||
|
||||
@[@6.1, @51.25, @1],
|
||||
@[@6.2, @51.7, @1],
|
||||
@[@6.3, @52.18, @1],
|
||||
@[@6.4, @52.63, @1],
|
||||
@[@6.5, @53.12, @1],
|
||||
@[@6.6, @53.49, @1],
|
||||
@[@6.7, @53.88, @1],
|
||||
@[@6.8, @54.28, @1],
|
||||
@[@6.9, @54.71, @1],
|
||||
@[@7.0, @55.15, @2],
|
||||
|
||||
@[@7.1, @55.53, @1],
|
||||
@[@7.2, @55.91, @1],
|
||||
@[@7.3, @56.36, @1],
|
||||
@[@7.4, @56.74, @1],
|
||||
@[@7.5, @57.09, @1],
|
||||
@[@7.6, @57.52, @1],
|
||||
@[@7.7, @57.89, @1],
|
||||
@[@7.8, @58.19, @1],
|
||||
@[@7.9, @58.56, @1],
|
||||
@[@8.0, @58.93, @3],
|
||||
];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame hasUltrawideCamera:(bool)hasUltrawideCamera hasTelephotoCamera:(bool)hasTelephotoCamera
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self != nil)
|
||||
{
|
||||
_hasUltrawideCamera = true;// hasUltrawideCamera;
|
||||
_hasTelephotoCamera = true;//hasTelephotoCamera;
|
||||
TGIsRetina();
|
||||
|
||||
_hasUltrawideCamera = hasUltrawideCamera;
|
||||
_hasTelephotoCamera = hasTelephotoCamera;
|
||||
|
||||
self.clipsToBounds = true;
|
||||
|
||||
CGFloat side = floor(frame.size.width * 1.1435);
|
||||
CGFloat length = 17.0;
|
||||
CGFloat smallWidth = MAX(0.5, 1.0 - TGScreenPixel);
|
||||
CGFloat mediumWidth = 1.0;
|
||||
CGFloat bigWidth = 1.0 + TGScreenPixel;
|
||||
|
||||
CGFloat smallAngle = M_PI * 0.12;
|
||||
CGFloat finalAngle = 1.08;
|
||||
CGFloat mediumWidth = smallWidth;
|
||||
CGFloat bigWidth = 1.0;
|
||||
|
||||
_backgroundView = [[UIImageView alloc] initWithImage:TGCircleImage(side, [UIColor colorWithWhite:0.0 alpha:0.75])];
|
||||
_backgroundView.frame = CGRectMake(TGScreenPixelFloor((frame.size.width - side) / 2.0), 0.0, side, side);
|
||||
[self addSubview:_backgroundView];
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(side, side), false, 0.0f);
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:0.0 alpha:0.75].CGColor);
|
||||
CGContextFillEllipseInRect(context, CGRectMake(0, 0, side, side));
|
||||
|
||||
[self _drawLineInContext:context side:side atAngle:0.0 lineLength:length lineWidth:bigWidth opaque:true];
|
||||
NSArray *ultraLines = [self ultraLines];
|
||||
NSArray *lines = [self lines];
|
||||
|
||||
if (_hasUltrawideCamera) {
|
||||
for (NSInteger i = 0; i < 4; i++) {
|
||||
CGFloat angle = (smallAngle / 5.0) * (i + 1) + (0.007 * (i - 1));
|
||||
[self _drawLineInContext:context side:side atAngle:-angle lineLength:length lineWidth:smallWidth opaque:false];
|
||||
for (NSArray *values in ultraLines) {
|
||||
CGFloat angle = [values[1] floatValue];
|
||||
CGFloat width = [values[2] intValue];
|
||||
|
||||
CGFloat lineWidth = smallWidth;
|
||||
if (width == 2) {
|
||||
lineWidth = mediumWidth;
|
||||
} else if (width == 3) {
|
||||
lineWidth = bigWidth;
|
||||
}
|
||||
[self _drawLineInContext:context side:side atAngle:TGDegreesToRadians(angle) lineLength:length lineWidth:lineWidth opaque:width > 1];
|
||||
}
|
||||
[self _drawLineInContext:context side:side atAngle:-smallAngle lineLength:length lineWidth:bigWidth opaque:true];
|
||||
}
|
||||
if (_hasTelephotoCamera) {
|
||||
[self _drawLineInContext:context side:side atAngle:smallAngle lineLength:length lineWidth:bigWidth opaque:true];
|
||||
for (NSArray *values in lines) {
|
||||
CGFloat angle = [values[1] floatValue];
|
||||
CGFloat width = [values[2] intValue];
|
||||
|
||||
for (NSInteger i = 0; i < 4; i++) {
|
||||
CGFloat angle = (smallAngle / 5.0) * (i + 1) + (0.01 * (i - 1));
|
||||
[self _drawLineInContext:context side:side atAngle:angle lineLength:length lineWidth:smallWidth opaque:false];
|
||||
CGFloat lineWidth = smallWidth;
|
||||
if (width == 2) {
|
||||
lineWidth = mediumWidth;
|
||||
} else if (width == 3) {
|
||||
lineWidth = bigWidth;
|
||||
}
|
||||
|
||||
[self _drawLineInContext:context side:side atAngle:finalAngle lineLength:length lineWidth:bigWidth opaque:true];
|
||||
} else {
|
||||
[self _drawLineInContext:context side:side atAngle:smallAngle lineLength:length lineWidth:mediumWidth opaque:true];
|
||||
|
||||
[self _drawLineInContext:context side:side atAngle:finalAngle lineLength:length lineWidth:bigWidth opaque:true];
|
||||
[self _drawLineInContext:context side:side atAngle:TGDegreesToRadians(angle) lineLength:length lineWidth:lineWidth opaque:width > 1];
|
||||
}
|
||||
|
||||
|
||||
UIImage *image = [UIGraphicsGetImageFromCurrentImageContext() stretchableImageWithLeftCapWidth:25 topCapHeight:25];
|
||||
|
||||
UIImage *scaleImage = [UIGraphicsGetImageFromCurrentImageContext() stretchableImageWithLeftCapWidth:25 topCapHeight:25];
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
_backgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(TGScreenPixelFloor((frame.size.width - side) / 2.0), 0.0, side, side)];
|
||||
_backgroundView.image = image;
|
||||
_containerView = [[UIView alloc] initWithFrame:CGRectMake(TGScreenPixelFloor((frame.size.width - side) / 2.0), 0.0, side, frame.size.height)];
|
||||
[self addSubview:_containerView];
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(side, frame.size.height), false, 0.0f);
|
||||
context = UIGraphicsGetCurrentContext();
|
||||
|
||||
[self addSubview:_backgroundView];
|
||||
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
|
||||
CGContextFillEllipseInRect(context, CGRectMake(0, 0, side, side));
|
||||
|
||||
CGContextSetBlendMode(context, kCGBlendModeClear);
|
||||
CGContextMoveToPoint(context, side / 2.0 - 7.0, 0);
|
||||
CGContextAddLineToPoint(context, side / 2.0 + 7.0, 0);
|
||||
CGContextAddLineToPoint(context, side / 2.0 + 2.0, 22);
|
||||
CGContextAddLineToPoint(context, side / 2.0 - 2.0, 22);
|
||||
CGContextClosePath(context);
|
||||
CGContextFillPath(context);
|
||||
|
||||
CGContextFillRect(context, CGRectMake(side / 2.0 - 1.0, 20, 2.0, 7.0));
|
||||
CGContextFillEllipseInRect(context, CGRectMake(side / 2.0 - 18.0, 20.0, 36.0, 36.0));
|
||||
|
||||
UIImage *maskImage = [UIGraphicsGetImageFromCurrentImageContext() stretchableImageWithLeftCapWidth:25 topCapHeight:25];
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
_maskView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, side, frame.size.height)];
|
||||
_maskView.image = maskImage;
|
||||
_containerView.maskView = _maskView;
|
||||
|
||||
_scaleView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, side, side)];
|
||||
_scaleView.image = scaleImage;
|
||||
[_containerView addSubview:_scaleView];
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(4, 10), false, 0.0f);
|
||||
context = UIGraphicsGetCurrentContext();
|
||||
|
||||
CGContextSetFillColorWithColor(context, [TGCameraInterfaceAssets accentColor].CGColor);
|
||||
CGContextMoveToPoint(context, 0, 0);
|
||||
CGContextAddLineToPoint(context, 4, 0);
|
||||
CGContextAddLineToPoint(context, 2 + TGScreenPixel, 10);
|
||||
CGContextAddLineToPoint(context, 2 - TGScreenPixel, 10);
|
||||
CGContextClosePath(context);
|
||||
CGContextFillPath(context);
|
||||
|
||||
UIImage *arrowImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
_arrowView = [[UIImageView alloc] initWithFrame:CGRectMake(floor((frame.size.width - 4) / 2.0), 4, 4, 10)];
|
||||
_arrowView.image = arrowImage;
|
||||
[self addSubview:_arrowView];
|
||||
|
||||
_valueLabel = [[UILabel alloc] init];
|
||||
_valueLabel.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_valueLabel.textColor = [TGCameraInterfaceAssets accentColor];
|
||||
[self addSubview:_valueLabel];
|
||||
|
||||
CGFloat radius = side / 2.0;
|
||||
if (_hasUltrawideCamera) {
|
||||
_05Label = [[UILabel alloc] init];
|
||||
_05Label.text = @"0,5";
|
||||
_05Label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_05Label.textColor = [UIColor whiteColor];
|
||||
[_05Label sizeToFit];
|
||||
[_scaleView addSubview:_05Label];
|
||||
|
||||
_05Label.center = CGPointMake(radius - sin(TGDegreesToRadians(19.6)) * (radius - 38.0), radius - cos(TGDegreesToRadians(19.6)) * (radius - 38.0));
|
||||
_05Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(-19.6));
|
||||
}
|
||||
|
||||
_1Label = [[UILabel alloc] init];
|
||||
_1Label.text = @"1";
|
||||
_1Label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_1Label.textColor = [UIColor whiteColor];
|
||||
[_1Label sizeToFit];
|
||||
_1Label.frame = CGRectMake(TGScreenPixelFloor((_scaleView.bounds.size.width - _1Label.frame.size.width) / 2.0), 30.0, _1Label.frame.size.width, _1Label.frame.size.height);
|
||||
[_scaleView addSubview:_1Label];
|
||||
|
||||
if (_hasTelephotoCamera) {
|
||||
_2Label = [[UILabel alloc] init];
|
||||
_2Label.text = @"2,0";
|
||||
_2Label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_2Label.textColor = [UIColor whiteColor];
|
||||
[_2Label sizeToFit];
|
||||
[_scaleView addSubview:_2Label];
|
||||
|
||||
_2Label.center = CGPointMake(radius - sin(TGDegreesToRadians(-19.6)) * (radius - 38.0), radius - cos(TGDegreesToRadians(-19.6)) * (radius - 38.0));
|
||||
_2Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(19.6));
|
||||
}
|
||||
|
||||
_8Label = [[UILabel alloc] init];
|
||||
_8Label.text = @"8";
|
||||
_8Label.font = [TGCameraInterfaceAssets boldFontOfSize:13.0];
|
||||
_8Label.textColor = [UIColor whiteColor];
|
||||
[_8Label sizeToFit];
|
||||
[_scaleView addSubview:_8Label];
|
||||
|
||||
_8Label.center = CGPointMake(radius - sin(TGDegreesToRadians(-58.93)) * (radius - 38.0), radius - cos(TGDegreesToRadians(-58.93)) * (radius - 38.0));
|
||||
_8Label.transform = CGAffineTransformMakeRotation(TGDegreesToRadians(58.93));
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -524,19 +745,47 @@
|
||||
zoomLevel = MAX(0.5, zoomLevel);
|
||||
_zoomLevel = zoomLevel;
|
||||
|
||||
CGFloat angle = 0.0;
|
||||
if (zoomLevel < 1.0) {
|
||||
CGFloat delta = (zoomLevel - 0.5) / 0.5;
|
||||
angle = TGDegreesToRadians(20.8) * (1.0 - delta);
|
||||
} else if (zoomLevel < 2.0) {
|
||||
CGFloat delta = zoomLevel - 1.0;
|
||||
angle = TGDegreesToRadians(-22.0) * delta;
|
||||
} else if (zoomLevel < 10.0) {
|
||||
CGFloat delta = (zoomLevel - 2.0) / 8.0;
|
||||
angle = TGDegreesToRadians(-22.0) + TGDegreesToRadians(-68.0) * delta;
|
||||
}
|
||||
NSArray *ultraLines = [self ultraLines];
|
||||
NSArray *lines = [self lines];
|
||||
|
||||
_backgroundView.transform = CGAffineTransformMakeRotation(angle);
|
||||
CGFloat finalAngle = 0.0;
|
||||
NSArray *allLines = [ultraLines arrayByAddingObjectsFromArray:lines];
|
||||
NSArray *previous = nil;
|
||||
for (NSArray *values in allLines) {
|
||||
CGFloat value = [values[0] floatValue];
|
||||
CGFloat angle = [values[1] floatValue];
|
||||
|
||||
if (previous == nil && zoomLevel <= value) {
|
||||
finalAngle = angle;
|
||||
break;
|
||||
}
|
||||
|
||||
if (previous != nil && zoomLevel < value) {
|
||||
CGFloat previousValue = [previous[0] floatValue];
|
||||
CGFloat previousAngle = [previous[1] floatValue];
|
||||
|
||||
if (zoomLevel > previousValue) {
|
||||
CGFloat factor = (zoomLevel - previousValue) / (value - previousValue);
|
||||
finalAngle = previousAngle + (angle - previousAngle) * factor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
previous = values;
|
||||
}
|
||||
finalAngle = -TGDegreesToRadians(finalAngle);
|
||||
|
||||
_scaleView.transform = CGAffineTransformMakeRotation(finalAngle);
|
||||
|
||||
CGFloat near = round(zoomLevel);
|
||||
NSString *value = [NSString stringWithFormat:@"%.1fx", zoomLevel];
|
||||
value = [value stringByReplacingOccurrencesOfString:@"." withString:@","];
|
||||
if (ABS(zoomLevel - near) < 0.05) {
|
||||
value = [NSString stringWithFormat:@"%dx", (int)near];
|
||||
}
|
||||
_valueLabel.text = value;
|
||||
[_valueLabel sizeToFit];
|
||||
|
||||
_valueLabel.frame = CGRectMake(TGScreenPixelFloor((self.frame.size.width - _valueLabel.frame.size.width) / 2.0), 30.0, _valueLabel.frame.size.width, _valueLabel.frame.size.height);
|
||||
}
|
||||
|
||||
- (void)setHidden:(BOOL)hidden
|
||||
|
Loading…
x
Reference in New Issue
Block a user