-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUICircularSlider.h
executable file
·116 lines (100 loc) · 4.36 KB
/
UICircularSlider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
/// UICircularSlider.h
/// UICircularSlider
//
// Created by Zouhair Mahieddine on 02/03/12.
// Copyright (c) 2012 Zouhair Mahieddine.
// http://www.zedenem.com
//
// This file is part of the UICircularSlider Library, released under the MIT License.
//
#if ! __has_feature(objc_arc)
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
#import <UIKit/UIKit.h>
/** @name Constants */
/**
* The styles permitted for the circular progress view.
*
* You can set and retrieve the current style of progress view through the progressViewStyle property.
*/
typedef enum {
UICircularSliderStyleCircle,
UICircularSliderStylePie,
} UICircularSliderStyle;
@interface UICircularSlider : UIControl
/**
* The current value of the receiver.
*
* Setting this property causes the receiver to redraw itself using the new value.
* If you try to set a value that is below the minimum or above the maximum value, the minimum or maximum value is set instead. The default value of this property is 0.0.
*/
@property (nonatomic) float value;
/**
* The minimum value of the receiver.
*
* If you change the value of this property, and the current value of the receiver is below the new minimum, the current value is adjusted to match the new minimum value automatically.
* The default value of this property is 0.0.
*/
@property (nonatomic) float minimumValue;
/**
* The maximum value of the receiver.
*
* If you change the value of this property, and the current value of the receiver is above the new maximum, the current value is adjusted to match the new maximum value automatically.
* The default value of this property is 1.0.
*/
@property (nonatomic) float maximumValue;
/**
* The color shown for the portion of the slider that is filled.
*/
@property(nonatomic, retain) UIColor *minimumTrackTintColor;
/**
* The color shown for the portion of the slider that is not filled.
*/
@property(nonatomic, retain) UIColor *maximumTrackTintColor;
/**
* The color used to tint the standard thumb.
*/
@property(nonatomic, retain) UIColor *thumbTintColor;
/**
* Contains a Boolean value indicating whether changes in the sliders value generate continuous update events.
*
* If YES, the slider sends update events continuously to the associated target’s action method.
* If NO, the slider only sends an action event when the user releases the slider’s thumb control to set the final value.
* The default value of this property is YES.
*/
@property(nonatomic, getter=isContinuous) BOOL continuous;
/**
* The current graphical style of the receiver.
*
* The value of this property is a constant that specifies the style of the slider.
The default style is UICircularSliderStyleCircle.
* For more on these constants, see UICircularSliderStyle.
*/
@property (nonatomic) UICircularSliderStyle sliderStyle;
@end
/** @name Utility Functions */
#pragma mark - Utility Functions
/**
* Translate a value in a source interval to a destination interval
* @param sourceValue The source value to translate
* @param sourceIntervalMinimum The minimum value in the source interval
* @param sourceIntervalMaximum The maximum value in the source interval
* @param destinationIntervalMinimum The minimum value in the destination interval
* @param destinationIntervalMaximum The maximum value in the destination interval
* @return The value in the destination interval
*
* This function uses the linear function method, a.k.a. resolves the y=ax+b equation where y is a destination value and x a source value
* Formulas : a = (dMax - dMin) / (sMax - sMin)
* b = dMax - a*sMax = dMin - a*sMin
*/
float translateValueFromSourceIntervalToDestinationInterval(float sourceValue, float sourceIntervalMinimum, float sourceIntervalMaximum, float destinationIntervalMinimum, float destinationIntervalMaximum);
/**
* Returns the smallest angle between three points, one of them clearly indicated as the "junction point" or "center point".
* @param centerPoint The "center point" or "junction point"
* @param p1 The first point, member of the [centerPoint p1] segment
* @param p2 The second point, member of the [centerPoint p2] segment
* @return The angle between those two segments
* This function uses the properties of the triangle and arctan (atan2f) function to calculate the angle.
*/
CGFloat angleBetweenThreePoints(CGPoint centerPoint, CGPoint p1, CGPoint p2);