Commit 971f74a5 cgx

完成圆弧进度条绘制

1 个父辈 03bfe323
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
D030C1B8284775930014946F /* RelaxTrainController.m in Sources */ = {isa = PBXBuildFile; fileRef = D030C1B7284775930014946F /* RelaxTrainController.m */; }; D030C1B8284775930014946F /* RelaxTrainController.m in Sources */ = {isa = PBXBuildFile; fileRef = D030C1B7284775930014946F /* RelaxTrainController.m */; };
D0336163285035AB005573CF /* DailyBgView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0336162285035AB005573CF /* DailyBgView.m */; }; D0336163285035AB005573CF /* DailyBgView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0336162285035AB005573CF /* DailyBgView.m */; };
D037B11228752A7E00236753 /* IndividualController.m in Sources */ = {isa = PBXBuildFile; fileRef = D037B11128752A7E00236753 /* IndividualController.m */; }; D037B11228752A7E00236753 /* IndividualController.m in Sources */ = {isa = PBXBuildFile; fileRef = D037B11128752A7E00236753 /* IndividualController.m */; };
D037B1162875635F00236753 /* ArcPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = D037B1142875635F00236753 /* ArcPath.swift */; };
D037B1172875635F00236753 /* DarwArcView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D037B1152875635F00236753 /* DarwArcView.swift */; };
D037C497284F4A22000F3089 /* SignTaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D037C496284F4A22000F3089 /* SignTaskView.m */; }; D037C497284F4A22000F3089 /* SignTaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D037C496284F4A22000F3089 /* SignTaskView.m */; };
D037C49A284F4F0D000F3089 /* DailyTaskCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D037C499284F4F0D000F3089 /* DailyTaskCell.m */; }; D037C49A284F4F0D000F3089 /* DailyTaskCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D037C499284F4F0D000F3089 /* DailyTaskCell.m */; };
D037C49D284F5DE8000F3089 /* TaskPointSrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = D037C49C284F5DE8000F3089 /* TaskPointSrollView.m */; }; D037C49D284F5DE8000F3089 /* TaskPointSrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = D037C49C284F5DE8000F3089 /* TaskPointSrollView.m */; };
...@@ -327,6 +329,9 @@ ...@@ -327,6 +329,9 @@
D0336162285035AB005573CF /* DailyBgView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DailyBgView.m; sourceTree = "<group>"; }; D0336162285035AB005573CF /* DailyBgView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DailyBgView.m; sourceTree = "<group>"; };
D037B11028752A7E00236753 /* IndividualController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IndividualController.h; sourceTree = "<group>"; }; D037B11028752A7E00236753 /* IndividualController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IndividualController.h; sourceTree = "<group>"; };
D037B11128752A7E00236753 /* IndividualController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IndividualController.m; sourceTree = "<group>"; }; D037B11128752A7E00236753 /* IndividualController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IndividualController.m; sourceTree = "<group>"; };
D037B1132875635E00236753 /* DreamSleep-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DreamSleep-Bridging-Header.h"; sourceTree = "<group>"; };
D037B1142875635F00236753 /* ArcPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArcPath.swift; sourceTree = "<group>"; };
D037B1152875635F00236753 /* DarwArcView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DarwArcView.swift; sourceTree = "<group>"; };
D037C495284F4A22000F3089 /* SignTaskView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SignTaskView.h; sourceTree = "<group>"; }; D037C495284F4A22000F3089 /* SignTaskView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SignTaskView.h; sourceTree = "<group>"; };
D037C496284F4A22000F3089 /* SignTaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SignTaskView.m; sourceTree = "<group>"; }; D037C496284F4A22000F3089 /* SignTaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SignTaskView.m; sourceTree = "<group>"; };
D037C498284F4F0D000F3089 /* DailyTaskCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DailyTaskCell.h; sourceTree = "<group>"; }; D037C498284F4F0D000F3089 /* DailyTaskCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DailyTaskCell.h; sourceTree = "<group>"; };
...@@ -915,8 +920,6 @@ ...@@ -915,8 +920,6 @@
D07257F5286C2F110080F458 /* SignCollectionViewCell.m */, D07257F5286C2F110080F458 /* SignCollectionViewCell.m */,
D037C49B284F5DE8000F3089 /* TaskPointSrollView.h */, D037C49B284F5DE8000F3089 /* TaskPointSrollView.h */,
D037C49C284F5DE8000F3089 /* TaskPointSrollView.m */, D037C49C284F5DE8000F3089 /* TaskPointSrollView.m */,
D0404A292870930A0062AD30 /* BeizerView.h */,
D0404A2A2870930A0062AD30 /* BeizerView.m */,
D01DC95828702F260035B78B /* RankViewCell.h */, D01DC95828702F260035B78B /* RankViewCell.h */,
D01DC95928702F260035B78B /* RankViewCell.m */, D01DC95928702F260035B78B /* RankViewCell.m */,
D01DC94F28701ECD0035B78B /* MyPointView.h */, D01DC94F28701ECD0035B78B /* MyPointView.h */,
...@@ -1205,6 +1208,7 @@ ...@@ -1205,6 +1208,7 @@
D091E662283F0BD400D3279E /* ScoreTaskAI */ = { D091E662283F0BD400D3279E /* ScoreTaskAI */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D0F258832876C5C90094F0F8 /* Arc */,
D01D3CD22873ED5900E65BAA /* Tool */, D01D3CD22873ED5900E65BAA /* Tool */,
D01D3CD12873ED1500E65BAA /* View */, D01D3CD12873ED1500E65BAA /* View */,
D01D3CD02873ECE000E65BAA /* Model */, D01D3CD02873ECE000E65BAA /* Model */,
...@@ -1383,6 +1387,7 @@ ...@@ -1383,6 +1387,7 @@
D0B5ECA327F2D9DE003EDFE3 /* DreamSleep */ = { D0B5ECA327F2D9DE003EDFE3 /* DreamSleep */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D0F258822876C3AB0094F0F8 /* Swift */,
D0FAC665281BB8A800D4B859 /* Class */, D0FAC665281BB8A800D4B859 /* Class */,
D0E9408127FE961300D57495 /* Vendors */, D0E9408127FE961300D57495 /* Vendors */,
D0FAC664281BB6FF00D4B859 /* Basement */, D0FAC664281BB6FF00D4B859 /* Basement */,
...@@ -1595,6 +1600,25 @@ ...@@ -1595,6 +1600,25 @@
path = Vendors; path = Vendors;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
D0F258822876C3AB0094F0F8 /* Swift */ = {
isa = PBXGroup;
children = (
D037B1132875635E00236753 /* DreamSleep-Bridging-Header.h */,
);
path = Swift;
sourceTree = "<group>";
};
D0F258832876C5C90094F0F8 /* Arc */ = {
isa = PBXGroup;
children = (
D0404A292870930A0062AD30 /* BeizerView.h */,
D0404A2A2870930A0062AD30 /* BeizerView.m */,
D037B1142875635F00236753 /* ArcPath.swift */,
D037B1152875635F00236753 /* DarwArcView.swift */,
);
path = Arc;
sourceTree = "<group>";
};
D0F808F628041FB60097899F /* BreathingMethod */ = { D0F808F628041FB60097899F /* BreathingMethod */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1958,6 +1982,7 @@ ...@@ -1958,6 +1982,7 @@
TargetAttributes = { TargetAttributes = {
D0B5ECA027F2D9DE003EDFE3 = { D0B5ECA027F2D9DE003EDFE3 = {
CreatedOnToolsVersion = 13.3; CreatedOnToolsVersion = 13.3;
LastSwiftMigration = 1330;
}; };
}; };
}; };
...@@ -2156,6 +2181,7 @@ ...@@ -2156,6 +2181,7 @@
D08F79E6281A198E000D99DD /* FeedImageCollectionCell.m in Sources */, D08F79E6281A198E000D99DD /* FeedImageCollectionCell.m in Sources */,
D07DACA52810557D0067A1BF /* RSKInternalUtility.m in Sources */, D07DACA52810557D0067A1BF /* RSKInternalUtility.m in Sources */,
D037B11228752A7E00236753 /* IndividualController.m in Sources */, D037B11228752A7E00236753 /* IndividualController.m in Sources */,
D037B1172875635F00236753 /* DarwArcView.swift in Sources */,
D08F79E0281A1838000D99DD /* TZImagePickerController.m in Sources */, D08F79E0281A1838000D99DD /* TZImagePickerController.m in Sources */,
D091E671283F2E6F00D3279E /* ScoreDetailListController.m in Sources */, D091E671283F2E6F00D3279E /* ScoreDetailListController.m in Sources */,
D07DACAB2810557D0067A1BF /* RSKImageScrollView.m in Sources */, D07DACAB2810557D0067A1BF /* RSKImageScrollView.m in Sources */,
...@@ -2196,6 +2222,7 @@ ...@@ -2196,6 +2222,7 @@
D0B1124A28631D8C00A496FB /* DSSlider.m in Sources */, D0B1124A28631D8C00A496FB /* DSSlider.m in Sources */,
D0336163285035AB005573CF /* DailyBgView.m in Sources */, D0336163285035AB005573CF /* DailyBgView.m in Sources */,
D0FAC421281B817D00D4B859 /* GKPhotoView.m in Sources */, D0FAC421281B817D00D4B859 /* GKPhotoView.m in Sources */,
D037B1162875635F00236753 /* ArcPath.swift in Sources */,
D091E66E283F29D100D3279E /* ScoreDetailController.m in Sources */, D091E66E283F29D100D3279E /* ScoreDetailController.m in Sources */,
D00A63572824C42300AFFEAA /* DSNetworkCache.m in Sources */, D00A63572824C42300AFFEAA /* DSNetworkCache.m in Sources */,
D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */, D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */,
...@@ -2405,11 +2432,13 @@ ...@@ -2405,11 +2432,13 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
App_Display_Name = "小梦睡眠-Dev"; App_Display_Name = "小梦睡眠-Dev";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepDebug.entitlements; CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepDebug.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 6; CURRENT_PROJECT_VERSION = 7;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 4NDZ6UX8PW; DEVELOPMENT_TEAM = 4NDZ6UX8PW;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
EXCLUDED_ARCHS = ""; EXCLUDED_ARCHS = "";
...@@ -2469,6 +2498,9 @@ ...@@ -2469,6 +2498,9 @@
PRODUCT_NAME = "小梦睡眠-Dev"; PRODUCT_NAME = "小梦睡眠-Dev";
PROVISIONING_PROFILE_SPECIFIER = xiaomengSleep_debug_profile; PROVISIONING_PROFILE_SPECIFIER = xiaomengSleep_debug_profile;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "DreamSleep/Swift/DreamSleep-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = 1;
}; };
name = Debug; name = Debug;
...@@ -2481,10 +2513,12 @@ ...@@ -2481,10 +2513,12 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
App_Display_Name = "小梦睡眠-冥想解压助眠健康养生"; App_Display_Name = "小梦睡眠-冥想解压助眠健康养生";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = DreamSleep/DreamSleep.entitlements; CODE_SIGN_ENTITLEMENTS = DreamSleep/DreamSleep.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 6; CURRENT_PROJECT_VERSION = 7;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 4NDZ6UX8PW; DEVELOPMENT_TEAM = 4NDZ6UX8PW;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
...@@ -2543,6 +2577,8 @@ ...@@ -2543,6 +2577,8 @@
PRODUCT_NAME = "小梦睡眠-冥想解压助眠健康养生"; PRODUCT_NAME = "小梦睡眠-冥想解压助眠健康养生";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "DreamSleep/Swift/DreamSleep-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = 1;
}; };
name = Release; name = Release;
...@@ -2617,11 +2653,13 @@ ...@@ -2617,11 +2653,13 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
App_Display_Name = "小梦睡眠-Beta"; App_Display_Name = "小梦睡眠-Beta";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepBeta.entitlements; CODE_SIGN_ENTITLEMENTS = DreamSleep/Basement/DSConfig/DreamSleepBeta.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 6; CURRENT_PROJECT_VERSION = 7;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 4NDZ6UX8PW; DEVELOPMENT_TEAM = 4NDZ6UX8PW;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
...@@ -2680,6 +2718,9 @@ ...@@ -2680,6 +2718,9 @@
PRODUCT_NAME = "小梦睡眠-Beta"; PRODUCT_NAME = "小梦睡眠-Beta";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "DreamSleep/Swift/DreamSleep-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = 1;
}; };
name = Beta; name = Beta;
......
...@@ -9,3 +9,5 @@ HOST_URL = https:${SLANT}/cbti.mynatapp.cc ...@@ -9,3 +9,5 @@ HOST_URL = https:${SLANT}/cbti.mynatapp.cc
//HEADER_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/unity_build_framework/UnityFramework.framework/Headers" //HEADER_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/unity_build_framework/UnityFramework.framework/Headers"
//FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/unity_build_framework" //FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/unity_build_framework"
//OTHER_LDFLAGS = $(inherited) -framework "UnityFramework" //OTHER_LDFLAGS = $(inherited) -framework "UnityFramework"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DSBETA=1
...@@ -6,3 +6,6 @@ ...@@ -6,3 +6,6 @@
/// 主机地址 /// 主机地址
SLANT = / SLANT = /
HOST_URL = https:${SLANT}/cbti.mynatapp.cc HOST_URL = https:${SLANT}/cbti.mynatapp.cc
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DSDEV=1
...@@ -328,7 +328,7 @@ ...@@ -328,7 +328,7 @@
[scoreCountLab mas_makeConstraints:^(MASConstraintMaker *make) { [scoreCountLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(titleLab); make.left.equalTo(titleLab);
make.bottom.equalTo(btn).offset(-10); make.bottom.equalTo(btn).offset(-10);
make.right.equalTo(btn).offset(-79); make.right.equalTo(btn).offset(-62);
}]; }];
} }
......
//
// ArcPath.swift
// CustomArcApiDemo
//
// Created by DR_Kun on 2020/5/16.
// Copyright © 2020 kun. All rights reserved.
//
import Foundation
import UIKit
extension UIBezierPath {
func addHumenArc(withCenter center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool) {
let rotationAdjustment = CGFloat(Double.pi * 0.5)
let modifiedStart = startAngle - rotationAdjustment
let modifiedEnd = endAngle - rotationAdjustment
addArc(withCenter: center, radius: radius, startAngle: modifiedStart, endAngle: modifiedEnd, clockwise: clockwise)
}
func addRotationArc(withCenter center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool, rotationAngle: CGFloat = .pi / 2) {
let modifiedStart = startAngle - rotationAngle
let modifiedEnd = endAngle - rotationAngle
addArc(withCenter: center, radius: radius, startAngle: modifiedStart, endAngle: modifiedEnd, clockwise: clockwise)
}
}
extension UIBezierPath {
/// Internal principle: Determine the position of the center of the circle through the `start` point, `end` point and `angle`.
/// And then draw the arc according to `clockwise`
///
/// Note: After the arc is drawn, the `move(to:)` method will be called to move to the `end` point.
/// - Parameters:
/// - start: The start point of the arc. (Note: This may not be the start point for drawing)
/// - end: The end point of the arc. (Note: This may not be the end point of the drawing)
/// - angle: The number of radians of the arc corresponding to the start point and end point;value must be between 0...2π
/// - clockwise: When the value is true, draw from start to end, when the value is false, draw from end to start
func addArc(startPoint start: CGPoint, endPoint end: CGPoint, angle: Double, clockwise: Bool) {
guard start != end && (angle >= 0 && angle <= 2 * Double.pi) else {
return
}
if angle == 0 {
move(to: start)
addLine(to: end)
return
}
var tmpStart = start, tmpEnd = end, tmpAngle = angle
// Note: 保证计算圆心时是从 start 到 end 小于 π 的角
if tmpAngle > Double.pi {
tmpAngle = 2 * Double.pi - tmpAngle
(tmpStart, tmpEnd) = (tmpEnd, tmpStart)
}
if !clockwise {
(tmpStart, tmpEnd) = (tmpEnd, tmpStart)
}
let center = calculateCenterFor(startPoint: tmpStart, endPoint: tmpEnd, radian: tmpAngle)
let radius = calculateLineLength(start, center)
var startAngle = calculateAngle(point: start, origin: center)
var endAngle = calculateAngle(point: end, origin: center)
// 如果逆时针绘制,则交换 startAngle 和 endAngle
if !clockwise {
(startAngle, endAngle) = (endAngle, startAngle)
move(to: end)
}
addArc(withCenter: center, radius: radius, startAngle: CGFloat(startAngle), endAngle: CGFloat(endAngle), clockwise: true)
move(to: end)
}
}
// MARK: 计算
extension UIBezierPath {
// Woring: 只计算从start到end **顺时针** 计算对应的 **小于π** 圆弧对应的圆心
// Note: 计算逆时针(end到start)可以看做将传入的start和end对调后计算顺时针时的圆心位置
// Note: 计算大于π的叫相当于将end和start对换后计算2π-angle的顺时针圆心位置
func calculateCenterFor(startPoint start: CGPoint, endPoint end: CGPoint, radian: Double) -> CGPoint {
guard radian <= Double.pi else {
fatalError("Does not support radian calculations greater than π!")
}
guard start != end else {
fatalError("Start position and end position cannot be equal!")
}
if radian == Double.pi {
let centerX = (end.x - start.x) * 0.5 + start.x
let centerY = (end.y - start.y) * 0.5 + start.y
return CGPoint(x: centerX, y: centerY)
}
let lineAB = calculateLineLength(start, end)
// 平行 Y 轴
if start.x == end.x {
let centerY = (end.y - start.y) * 0.5 + start.y
let tanResult = CGFloat(tan(radian * 0.5))
let offsetX = lineAB * 0.5 / tanResult
let centerX = start.x + offsetX * (start.y > end.y ? 1.0 : -1.0)
return CGPoint(x: centerX, y: centerY)
}
// 平行 X 轴
if start.y == end.y {
let centerX = (end.x - start.x) * 0.5 + start.x
let tanResult = CGFloat(tan(radian * 0.5))
let offsetY = lineAB * 0.5 / tanResult
let centerY = start.y + offsetY * (start.x < end.x ? 1.0 : -1.0)
return CGPoint(x: centerX, y: centerY)
}
// 普通情况
// 计算半径
let radius = lineAB * 0.5 / CGFloat(sin(radian * 0.5))
// 计算与 Y 轴的夹角
let angleToYAxis = atan(abs(start.x - end.x) / abs(start.y - end.y))
let cacluteAngle = CGFloat(Double.pi - radian) * 0.5 - angleToYAxis
// 偏移量
let offsetX = radius * sin(cacluteAngle)
let offsetY = radius * cos(cacluteAngle)
var centetX = end.x
var centerY = end.y
// 以 start 为原点判断象限区间
if end.x > start.x && end.y < start.y {
// 第一象限
centetX = end.x + offsetX
centerY = end.y + offsetY
} else if end.x > start.x && end.y > start.y {
// 第二象限
centetX = start.x - offsetX
centerY = start.y + offsetY
} else if end.x < start.x && end.y > start.y {
// 第三象限
centetX = end.x - offsetX
centerY = end.y - offsetY
} else if end.x < start.x && end.y < start.y {
// 第四象限
centetX = start.x + offsetX
centerY = start.y - offsetY
}
return CGPoint(x: centetX, y: centerY)
}
func calculateAngle(point: CGPoint, origin: CGPoint) -> Double {
if point.y == origin.y {
return point.x > origin.x ? 0.0 : -Double.pi
}
if point.x == origin.x {
return point.y > origin.y ? Double.pi * 0.5 : Double.pi * -0.5
}
// Note: 修正标准坐标系角度到 iOS 坐标系
let rotationAdjustment = Double.pi * 0.5
let offsetX = point.x - origin.x
let offsetY = point.y - origin.y
// 使用 -offsetY 是因为 iOS 坐标系与标准坐标系的区别
if offsetY > 0 {
return Double(atan(offsetX / -offsetY)) + rotationAdjustment
} else {
return Double(atan(offsetX / -offsetY)) - rotationAdjustment
}
}
func calculateLineLength(_ point1: CGPoint, _ point2: CGPoint) -> CGFloat {
let w = point1.x - point2.x
let h = point1.y - point2.y
return sqrt(w * w + h * h)
}
}
...@@ -11,8 +11,13 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -11,8 +11,13 @@ NS_ASSUME_NONNULL_BEGIN
/// 自定义贝塞尔曲线 /// 自定义贝塞尔曲线
@interface BeizerView : UIView @interface BeizerView : UIView
@property (nonatomic, assign) float progressRate; @property (nonatomic, assign) float progressRate;
- (void)animateProgress:(float)progress animate:(BOOL)animate; - (void)animateProgress:(float)progress animate:(BOOL)animate;
+ (void)drawLinearGradient:(CGContextRef)context path:(CGPathRef)path startColor:(CGColorRef)startColor endColor:(CGColorRef)endColor;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
} }
- (void)drawRect:(CGRect)rect { - (void)drawRect:(CGRect)rect {
CGFloat x = 0, y = 0, width = self.width, height = self.height; self.clipsToBounds = YES;
CGFloat x = 0, y = 0, width = self.width+2, height = self.height - 4;
CGPoint center = CGPointMake(x + width / 2.0, y + height / 2.0); CGPoint center = CGPointMake(x + width / 2.0, y + height / 2.0);
CGFloat startAngle = 95*M_PI_2/90; CGFloat startAngle = 95*M_PI_2/90;
...@@ -33,7 +35,7 @@ ...@@ -33,7 +35,7 @@
// 总曲线 // 总曲线
UIBezierPath *totalClip = [UIBezierPath bezierPathWithArcCenter:center UIBezierPath *totalClip = [UIBezierPath bezierPathWithArcCenter:center
radius:MAX(width, height) radius:MAX(width, height)
startAngle:M_PI_2 startAngle:M_PI_2+1
endAngle:0 endAngle:0
clockwise:NO]; clockwise:NO];
[totalClip addLineToPoint:center]; [totalClip addLineToPoint:center];
...@@ -41,21 +43,27 @@ ...@@ -41,21 +43,27 @@
[totalClip addClip]; [totalClip addClip];
UIBezierPath *totalArc = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x, y, width, height)]; UIBezierPath *totalArc = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x, y, width, height)];
[[UIColor redColor] setStroke]; totalArc.lineWidth = 2.0;
[ColorFromHex(0x217B8B) setStroke];
[totalArc stroke]; [totalArc stroke];
// CGContextRef gc = UIGraphicsGetCurrentContext();
// [self drawLinearGradient:gc path:totalArc.CGPath startColor:ColorFromHex(0x9CE5EF).CGColor endColor:ColorFromHex(0x217B8B).CGColor];
// 当前曲线 // 当前曲线
UIBezierPath* curClip = [UIBezierPath bezierPathWithArcCenter:center UIBezierPath *curClip = [UIBezierPath bezierPathWithArcCenter:center
radius:MAX(width, height) radius:MAX(width, height)
startAngle:startAngle startAngle:startAngle
endAngle:endAngle2 endAngle:endAngle2
clockwise:NO]; clockwise:NO];
curClip.lineWidth = 2.0;
[curClip addLineToPoint:center]; [curClip addLineToPoint:center];
[curClip closePath]; [curClip closePath];
[curClip addClip]; [curClip addClip];
UIBezierPath *curArc = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x, y, width, height)]; UIBezierPath *curArc = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x, y, width, height)];
[[UIColor greenColor] setStroke]; curArc.lineWidth = 2.0;
[DSWhite setStroke];
[curArc stroke]; [curArc stroke];
// CGPoint center = CGPointMake(67, -508); // CGPoint center = CGPointMake(67, -508);
...@@ -136,8 +144,7 @@ ...@@ -136,8 +144,7 @@
// [layer addAnimation:animation forKey:nil]; // [layer addAnimation:animation forKey:nil];
} }
-(void)animateProgress:(float)progress animate:(BOOL)animate - (void)animateProgress:(float)progress animate:(BOOL)animate {
{
if (animate) { if (animate) {
self.total = progress; self.total = progress;
/* /*
...@@ -153,7 +160,7 @@ ...@@ -153,7 +160,7 @@
} }
} }
-(void)numberAnimation:(NSTimer*)timer { - (void)numberAnimation:(NSTimer*)timer {
_step += 0.01; _step += 0.01;
if (self.step > self.total) { if (self.step > self.total) {
[timer invalidate]; [timer invalidate];
...@@ -168,6 +175,28 @@ ...@@ -168,6 +175,28 @@
[self setNeedsDisplay]; [self setNeedsDisplay];
} }
#pragma mark - 线性渐变色
+ (void)drawLinearGradient:(CGContextRef)context path:(CGPathRef)path startColor:(CGColorRef)startColor endColor:(CGColorRef)endColor {
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGFloat locations[] = {0.0, 1.0, 0.0, 1.0};
NSArray *colors = @[(__bridge id)startColor, (__bridge id)endColor];
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)colors, locations);
CGRect pathRect = CGPathGetBoundingBox(path);
CGPoint startPoint = CGPointMake(CGRectGetMinX(pathRect), CGRectGetMidY(pathRect));
CGPoint endPoint = CGPointMake(CGRectGetMaxX(pathRect), CGRectGetMidY(pathRect));
CGContextSaveGState(context);
CGContextAddPath(context, path);
CGContextClip(context);
CGContextStrokePath(context);
CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
CGContextRestoreGState(context);
CGGradientRelease(gradient);
CGColorSpaceRelease(colorSpace);
}
#pragma mark - others #pragma mark - others
- (void)addArc:(CGPoint)start end:(CGPoint)end angle:(double)angle clockwise:(BOOL)clockwise path:(UIBezierPath *)path { - (void)addArc:(CGPoint)start end:(CGPoint)end angle:(double)angle clockwise:(BOOL)clockwise path:(UIBezierPath *)path {
if (!((start.x != end.x || start.y != end.y) && (angle >= 0 && angle <= 2 * M_PI))) { if (!((start.x != end.x || start.y != end.y) && (angle >= 0 && angle <= 2 * M_PI))) {
......
//
// DarwArcView.swift
// CustomArcApiDemo
//
// Created by DR_Kun on 2020/5/15.
// Copyright © 2020 kun. All rights reserved.
//
import UIKit
extension String {
func widthWithConstrainedHeight(height: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: CGFloat.greatestFiniteMagnitude, height: height)
let option = NSStringDrawingOptions.usesFontLeading.union(.usesLineFragmentOrigin)
let boundingBox = self.boundingRect(with: constraintRect, options: option, attributes: [NSAttributedString.Key.font: font], context: nil)
return boundingBox.width
}
}
/// 圆弧绘制
class DarwArcView: UIView {
/// 当前等级
var cur_rank: String = ""
/// 下一个等级
var next_rank: String = ""
/// 当前进度
var progress: Double = 0.0
override init(frame: CGRect){
super.init(frame: frame)
backgroundColor = .clear
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
/// 绘制当前等级和下一等级文本
/// - Parameters:
/// - curText: 当前等级
/// - nextText: 下一等级
/// - Returns: void
@objc func updateText(curText: String, nextText: String) -> Void {
self.cur_rank = curText
self.next_rank = nextText
setNeedsDisplay()
}
/// 更新当前用户等级进度
/// - Parameter progress: progress
@objc func updateCurProgress(progress: Double) {
self.progress = progress
setNeedsDisplay()
}
override func draw(_ rect: CGRect) {
// 圆弧起始点距离当前控件底部间距
let space = 36.0
// 小圆点半径
let dotRadius = 4.0
// 总圆弧开始点
let total_start = CGPoint(x: 0, y: rect.height - 2*dotRadius - space)
// 总圆弧结束点
let total_end = CGPoint(x: rect.width, y: 2*dotRadius)
// 总圆弧对应的圆心角度(弧度)
let angle = Double.pi / 6.0;
// 总圆弧填充色
let strokeColor = UIColor.init(red: 33/255.0, green: 123/255.0, blue: 139/255.0, alpha: 1.0)
// 绘制总圆弧进度条
let totalPath = UIBezierPath()
totalPath.addArc(startPoint: total_start, endPoint: total_end, angle: angle, clockwise: false)
totalPath.lineWidth = 2.0
strokeColor.setStroke()
totalPath.stroke()
let curPath = UIBezierPath()
// 根据圆弧起始结束点及弧度计算圆心坐标
let center = curPath.calculateCenterFor(startPoint: total_end, endPoint: total_start, radian: angle)
// 根据圆心和圆弧上的点计算圆弧半径
let radius = curPath.calculateLineLength(total_start, center)
// 计算起始角度
let startAngle = curPath.calculateAngle(point: total_start, origin: center)
// 计算结束角度
let endAngle = curPath.calculateAngle(point: total_end, origin: center)
print("startAngle:\(startAngle), endAngele:\(endAngle)")
// 确定当前等级角度
let curLevelAngle = startAngle - 0.1
// 确定下一等级角度
let nextLevelAngle = endAngle + 0.1
// 当前等级和下一等级点直接圆弧角度
let realAngle = curLevelAngle - nextLevelAngle
// 当前进度所对应的角度
let curProgressAngle = curLevelAngle - progress * realAngle;
// 绘制当前进度圆弧
curPath.addArc(withCenter: center, radius: radius, startAngle: startAngle, endAngle: curProgressAngle, clockwise: false)
// 进度条动画
let anLayer = CAShapeLayer()
anLayer.lineWidth = 2.0
anLayer.fillColor = UIColor.clear.cgColor
anLayer.strokeColor = UIColor.white.cgColor;
self.layer.addSublayer(anLayer)
anLayer.path = curPath.cgPath;
// 创建Animation
let animation = CABasicAnimation(keyPath: "strokeEnd")
animation.fromValue = 0.0
animation.toValue = 1.0
animation.autoreverses = false
animation.duration = 2.0
anLayer.add(animation, forKey: nil)
// 计算当前等级小圆点在圆弧上点的坐标
let x1 = (Float)(radius) * cosf((Float)(curLevelAngle))
let y1 = (Float)(radius) * sinf((Float)(curLevelAngle))
let curCenter = CGPoint(x: center.x + (CGFloat)(x1), y: center.y + (CGFloat)(y1))
// 计算下一等级小圆点在圆弧上点的坐标
let x2 = (Float)(radius) * cosf((Float)(nextLevelAngle))
let y2 = (Float)(radius) * sinf((Float)(nextLevelAngle))
let nextCenter = CGPoint(x: center.x + (CGFloat)(x2), y: center.y + (CGFloat)(y2))
// 绘制当前等级点和下一等级点
let curLevealDotPath = UIBezierPath()
UIColor.white.setFill()
UIColor.white.setStroke()
curLevealDotPath.addArc(withCenter: curCenter, radius: dotRadius, startAngle: 0, endAngle: Double.pi*2, clockwise: true)
curLevealDotPath.fill()
curLevealDotPath.stroke()
let nextLevealDotPath = UIBezierPath()
strokeColor.setFill()
strokeColor.setStroke()
nextLevealDotPath.addArc(withCenter: nextCenter, radius: dotRadius, startAngle: 0, endAngle: Double.pi*2, clockwise: true)
nextLevealDotPath.fill()
nextLevealDotPath.stroke()
// 绘制文本
let textFont = UIFont.boldSystemFont(ofSize: 12.0)
let textFillColor = UIColor.init(red: 69/255.0, green: 153/255.0, blue: 168/255.0, alpha: 1.0)
let attributes = [NSAttributedString.Key.font:textFont, NSAttributedString.Key.foregroundColor:textFillColor]
let curTextW = cur_rank.widthWithConstrainedHeight(height: 17.0, font: textFont)
let nextTextW = next_rank.widthWithConstrainedHeight(height: 17.0, font: textFont)
let fixCurPoint = CGPoint(x: curCenter.x - curTextW/2.0, y: curCenter.y + 8)
let fixNextPoint = CGPoint(x: nextCenter.x - nextTextW/2.0, y: nextCenter.y + 20)
let curText = cur_rank as NSString
let nextText = next_rank as NSString
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(textFillColor.cgColor)
context?.setTextDrawingMode(.fill)
curText.draw(at: fixCurPoint, withAttributes:attributes)
nextText.draw(at: fixNextPoint, withAttributes:attributes)
}
}
extension DarwArcView {
// 渐变色实现方案
// 无限分割圆弧,逐个进行渐变色
// let width = rect.width
// let height = rect.height
// let diameter = 2*radius
//
// // 裁剪圆环
// let bPath = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: width, height: height))
// bPath.usesEvenOddFillRule = true
// let lineWidth = 2
// bPath.append(totalPath)
// bPath.addClip()
//
// let arcStep = 2*Double.pi / 360.0
// let clocklwise = false
// let x = rect.width/2
// let y = rect.height/2
//
// let contet = UIGraphicsGetCurrentContext()
// contet?.setLineWidth(radius * 2)
// for i in 0..<360 {
// let c = UIColor(hue: CGFloat(i)/360.0, saturation: 1.0, brightness: 1.0, alpha: 1.0)
// contet?.setStrokeColor(c.cgColor)
// let startAngle = (Double)(i)*arcStep
// let endAngle = startAngle + arcStep + 0.02
// contet?.addArc(center: CGPoint(x: x, y: y), radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: false)
// contet?.strokePath()
// }
// 渐变色(区域渐变色)
// let startColor = UIColor.init(red: 156/255.0, green: 229/255.0, blue: 239/255.0, alpha: 1.0)
// let endColor = UIColor.init(red: 33/255.0, green: 123/255.0, blue: 139/255.0, alpha: 1.0)
// BeizerView.drawLinearGradient(UIGraphicsGetCurrentContext()!, path: totalPath.cgPath, start: startColor.cgColor, end: endColor.cgColor)
}
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
@interface DailyBgView () @interface DailyBgView ()
@property (nonatomic, strong) UIImageView *bgIV; @property (nonatomic, strong) UIImageView *bgIV;
@property (nonatomic, strong) DPScrollNumberLabel *pointsLab; @property (nonatomic, strong) UILabel *pointsLab;
@property (nonatomic, strong) UILabel *todayLab; @property (nonatomic, strong) UILabel *todayLab;
@end @end
...@@ -27,12 +27,11 @@ ...@@ -27,12 +27,11 @@
- (void)updateTodayPointData:(int)points { - (void)updateTodayPointData:(int)points {
// 积分需要动画显示效果 // 积分需要动画显示效果
[self.pointsLab changeToNumber:@(points) animated:YES]; self.pointsLab.text = [NSString stringWithFormat:@"%d", points];
self.todayLab.text = @"今日积分"; self.todayLab.text = @"今日积分";
[self.pointsLab mas_remakeConstraints:^(MASConstraintMaker *make) { [self.pointsLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15); make.left.equalTo(self).offset(15);
make.top.equalTo(self).offset(136); make.top.equalTo(self).offset(136);
make.size.mas_equalTo(CGSizeMake(self.pointsLab.frame.size.width, self.pointsLab.frame.size.height));
}]; }];
[self.todayLab mas_makeConstraints:^(MASConstraintMaker *make) { [self.todayLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.pointsLab.mas_right).offset(2); make.left.equalTo(self.pointsLab.mas_right).offset(2);
...@@ -49,10 +48,10 @@ ...@@ -49,10 +48,10 @@
return _bgIV; return _bgIV;
} }
- (DPScrollNumberLabel *)pointsLab { - (UILabel *)pointsLab {
if (!_pointsLab) { if (!_pointsLab) {
_pointsLab = [[DPScrollNumberLabel alloc] initWithNumber:@(0) fontSize:46.0 signSetting:SignSettingUnsigned]; _pointsLab = [UILabel labWithFont:BoldFont(46.0)];
_pointsLab.minRowNumber = 1; _pointsLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
} }
return _pointsLab; return _pointsLab;
} }
......
...@@ -8,6 +8,13 @@ ...@@ -8,6 +8,13 @@
#import "ScoreLevelView.h" #import "ScoreLevelView.h"
#import "BeizerView.h" #import "BeizerView.h"
#import "ScoreRulesView.h" #import "ScoreRulesView.h"
#if DSDEV
#import "DreamSleepDev-Swift.h"
#elif DSBETA
#import "DreamSleepBeta-Swift.h"
#elif DSRELEASE
#import "DreamSleep-Swift.h"
#endif
@interface ScoreLevelView () @interface ScoreLevelView ()
@property (nonatomic, strong) UIImageView *cardIV; @property (nonatomic, strong) UIImageView *cardIV;
...@@ -15,9 +22,7 @@ ...@@ -15,9 +22,7 @@
@property (nonatomic, strong) UILabel *totalPointsLab; @property (nonatomic, strong) UILabel *totalPointsLab;
@property (nonatomic, strong) UIImageView *rewardIV; @property (nonatomic, strong) UIImageView *rewardIV;
@property (nonatomic, strong) UIButton *rulesBtn; @property (nonatomic, strong) UIButton *rulesBtn;
@property (nonatomic, strong) UILabel *curRankLab; @property (nonatomic, strong) DarwArcView *arcView;
@property (nonatomic, strong) UILabel *nextRankLab;
@property (nonatomic, strong) BeizerView *arcBeizerView;
@property (nonatomic, strong) ScoreRulesView *scoreRulesView; @property (nonatomic, strong) ScoreRulesView *scoreRulesView;
@property (nonatomic, strong) NSArray *rulesArr; @property (nonatomic, strong) NSArray *rulesArr;
@end @end
...@@ -30,9 +35,7 @@ ...@@ -30,9 +35,7 @@
[self addSubview:self.curRankNameLab]; [self addSubview:self.curRankNameLab];
[self addSubview:self.totalPointsLab]; [self addSubview:self.totalPointsLab];
[self addSubview:self.rewardIV]; [self addSubview:self.rewardIV];
[self addSubview:self.curRankLab]; [self.cardIV addSubview:self.arcView];
[self addSubview:self.nextRankLab];
[self addSubview:self.arcBeizerView];
[self addSubview:self.rulesBtn]; [self addSubview:self.rulesBtn];
CGFloat h = 150*(kScreenWidth - 30)/345; CGFloat h = 150*(kScreenWidth - 30)/345;
...@@ -52,29 +55,11 @@ ...@@ -52,29 +55,11 @@
make.right.equalTo(self.cardIV).offset(-9); make.right.equalTo(self.cardIV).offset(-9);
make.size.mas_equalTo(CGSizeMake(64, 21)); make.size.mas_equalTo(CGSizeMake(64, 21));
}]; }];
[self.arcBeizerView mas_makeConstraints:^(MASConstraintMaker *make) { [self.arcView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.cardIV); make.left.right.equalTo(self.cardIV);
make.left.equalTo(self.cardIV).offset(-self.cardIV.width); make.bottom.equalTo(self.cardIV).offset(0);
make.bottom.equalTo(self.cardIV).offset(-36); make.top.equalTo(self.cardIV).offset(38);
make.top.equalTo(self.cardIV).offset(-38);
}]; }];
// 截图方法
// [self.curBeizerView mas_makeConstraints:^(MASConstraintMaker *make) {
// // make.left.top.bottom.right.equalTo(self.totalBeizerView);
// make.left.top.bottom.equalTo(self.totalBeizerView);
// make.right.equalTo(self.totalBeizerView).offset(-100);
// }];
// [self.curBeizerView layoutIfNeeded];
// UIImage *imge = [self.curBeizerView snapshotImage:CGSizeMake(200, self.curBeizerView.height)];
// UIImageView *iv = [UIImageView new];
// iv.image = imge;
// iv.backgroundColor = DSClearColor;
// [self addSubview:iv];
// [iv mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.left.bottom.equalTo(self.totalBeizerView);
// make.width.equalTo(@200);
// }];
// self.curBeizerView.hidden = YES;
} }
return self; return self;
} }
...@@ -85,11 +70,9 @@ ...@@ -85,11 +70,9 @@
self.curRankNameLab.text = scoreModel.rank_name; self.curRankNameLab.text = scoreModel.rank_name;
self.totalPointsLab.text = [NSString stringWithFormat:@"总积分:%ld", scoreModel.total_points]; self.totalPointsLab.text = [NSString stringWithFormat:@"总积分:%ld", scoreModel.total_points];
[self.rewardIV yy_setImageWithURL:[NSURL URLWithString:scoreModel.reward_img] placeholder:[UIImage imageNamed:@"basicPlaceholder"]]; [self.rewardIV yy_setImageWithURL:[NSURL URLWithString:scoreModel.reward_img] placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
self.curRankLab.text = scoreModel.cur_rank; [self.arcView updateTextWithCurText:scoreModel.cur_rank nextText:scoreModel.next_rank];
self.nextRankLab.text = scoreModel.next_rank;
double progress = (double)scoreModel.total_points / (double)scoreModel.next_min_point; double progress = (double)scoreModel.total_points / (double)scoreModel.next_min_point;
DSLog(@"progress:%f", progress); [self.arcView updateCurProgressWithProgress:progress];
[self.arcBeizerView animateProgress:1.0 animate:YES];
[self.curRankNameLab mas_makeConstraints:^(MASConstraintMaker *make) { [self.curRankNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.cardIV).offset(20); make.left.equalTo(self.cardIV).offset(20);
...@@ -99,14 +82,6 @@ ...@@ -99,14 +82,6 @@
make.left.equalTo(self.curRankNameLab); make.left.equalTo(self.curRankNameLab);
make.top.equalTo(self.curRankNameLab.mas_bottom).offset(16); make.top.equalTo(self.curRankNameLab.mas_bottom).offset(16);
}]; }];
[self.curRankLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.cardIV).offset(15);
make.bottom.equalTo(self.cardIV).offset(-12);
}];
[self.nextRankLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.cardIV).offset(-17);
make.bottom.equalTo(self.cardIV).offset(-41);
}];
} }
#pragma mark - lazy #pragma mark - lazy
...@@ -151,26 +126,11 @@ ...@@ -151,26 +126,11 @@
return _rulesBtn; return _rulesBtn;
} }
- (UILabel *)curRankLab { - (DarwArcView *)arcView {
if (!_curRankLab) { if (!_arcView) {
_curRankLab = [UILabel labWithTextColor:ColorFromHex(0x4599A8) font:BoldFont(12)]; _arcView = [DarwArcView new];
}
return _curRankLab;
}
- (UILabel *)nextRankLab {
if (!_nextRankLab) {
_nextRankLab = [UILabel labWithTextColor:ColorFromHex(0x4599A8) font:BoldFont(12)];
_nextRankLab.textAlignment = NSTextAlignmentRight;
}
return _nextRankLab;
}
- (BeizerView *)arcBeizerView {
if (!_arcBeizerView) {
_arcBeizerView = [BeizerView new];
} }
return _arcBeizerView; return _arcView;
} }
- (ScoreRulesView *)scoreRulesView { - (ScoreRulesView *)scoreRulesView {
......
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "BeizerView.h"
...@@ -7,77 +7,77 @@ ...@@ -7,77 +7,77 @@
<key>AFNetworking.xcscheme_^#shared#^_</key> <key>AFNetworking.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>4</integer> <integer>9</integer>
</dict> </dict>
<key>DKNightVersion.xcscheme_^#shared#^_</key> <key>DKNightVersion.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>16</integer> <integer>11</integer>
</dict> </dict>
<key>DOUAudioStreamer.xcscheme_^#shared#^_</key> <key>DOUAudioStreamer.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>10</integer> <integer>5</integer>
</dict> </dict>
<key>FreeStreamer.xcscheme_^#shared#^_</key> <key>FreeStreamer.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>17</integer>
</dict> </dict>
<key>IQKeyboardManager.xcscheme_^#shared#^_</key> <key>IQKeyboardManager.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>7</integer> <integer>6</integer>
</dict> </dict>
<key>MBProgressHUD.xcscheme_^#shared#^_</key> <key>MBProgressHUD.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>17</integer> <integer>13</integer>
</dict> </dict>
<key>MJRefresh.xcscheme_^#shared#^_</key> <key>MJRefresh.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>11</integer> <integer>15</integer>
</dict> </dict>
<key>Masonry.xcscheme_^#shared#^_</key> <key>Masonry.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>6</integer> <integer>10</integer>
</dict> </dict>
<key>Pods-DreamSleep.xcscheme_^#shared#^_</key> <key>Pods-DreamSleep.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>8</integer> <integer>14</integer>
</dict> </dict>
<key>Reachability.xcscheme_^#shared#^_</key> <key>Reachability.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>12</integer> <integer>7</integer>
</dict> </dict>
<key>YYCache.xcscheme_^#shared#^_</key> <key>YYCache.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>14</integer> <integer>12</integer>
</dict> </dict>
<key>YYImage.xcscheme_^#shared#^_</key> <key>YYImage.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>18</integer> <integer>16</integer>
</dict> </dict>
<key>YYModel.xcscheme_^#shared#^_</key> <key>YYModel.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>9</integer> <integer>19</integer>
</dict> </dict>
<key>YYWebImage.xcscheme_^#shared#^_</key> <key>YYWebImage.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>19</integer> <integer>18</integer>
</dict> </dict>
<key>lottie-ios.xcscheme_^#shared#^_</key> <key>lottie-ios.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>15</integer> <integer>8</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<key>UnityFramework.xcscheme_^#shared#^_</key> <key>UnityFramework.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>13</integer> <integer>4</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!