├── README.md
├── ZYDMonitorDemo
├── ZYDMonitor
│ ├── Base.lproj
│ │ └── MainInterface.storyboard
│ ├── Info.plist
│ ├── Reachability.h
│ ├── Reachability.m
│ ├── TodayViewController.h
│ ├── TodayViewController.m
│ ├── WMGaugeView.h
│ ├── WMGaugeView.m
│ └── ZYDMonitor.entitlements
├── ZYDMonitorDemo.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── zyd.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── zyd.xcuserdatad
│ │ └── xcschemes
│ │ ├── ZYDMonitor.xcscheme
│ │ ├── ZYDMonitorDemo.xcscheme
│ │ └── xcschememanagement.plist
├── ZYDMonitorDemo
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── snow.imageset
│ │ │ ├── Contents.json
│ │ │ └── 雪花.png
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── UIView+Category.h
│ ├── UIView+Category.m
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── ZYDMonitorDemo.entitlements
│ └── main.m
├── ZYDMonitorDemoTests
│ ├── Info.plist
│ └── ZYDMonitorDemoTests.m
└── ZYDMonitorDemoUITests
│ ├── Info.plist
│ └── ZYDMonitorDemoUITests.m
└── image
└── show.png
/README.md:
--------------------------------------------------------------------------------
1 | # ZYDMonitor
2 | 一个 Today 的插件,可以监测内存、磁盘空间、cup
3 | 实时监测 上行、下行网速。
4 | 
5 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/Base.lproj/MainInterface.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
30 |
40 |
50 |
60 |
70 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
97 |
98 |
99 |
100 |
110 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
139 |
149 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | 叫我“无敌丿小东哥”——LOL
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | XPC!
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | NSExtension
26 |
27 | NSExtensionMainStoryboard
28 | MainInterface
29 | NSExtensionPointIdentifier
30 | com.apple.widget-extension
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/Reachability.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2011, Tony Million.
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #import
29 | #import
30 |
31 | //! Project version number for MacOSReachability.
32 | FOUNDATION_EXPORT double ReachabilityVersionNumber;
33 |
34 | //! Project version string for MacOSReachability.
35 | FOUNDATION_EXPORT const unsigned char ReachabilityVersionString[];
36 |
37 | /**
38 | * Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X.
39 | *
40 | * @see http://nshipster.com/ns_enum-ns_options/
41 | **/
42 | #ifndef NS_ENUM
43 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
44 | #endif
45 |
46 | extern NSString *const kReachabilityChangedNotification;
47 |
48 | typedef NS_ENUM(NSInteger, NetworkStatus) {
49 | // Apple NetworkStatus Compatible Names.
50 | NotReachable = 0,
51 | ReachableViaWiFi = 2,
52 | ReachableViaWWAN = 1
53 | };
54 |
55 | @class Reachability;
56 |
57 | typedef void (^NetworkReachable)(Reachability * reachability);
58 | typedef void (^NetworkUnreachable)(Reachability * reachability);
59 | typedef void (^NetworkReachability)(Reachability * reachability, SCNetworkConnectionFlags flags);
60 |
61 |
62 | @interface Reachability : NSObject
63 |
64 | @property (nonatomic, copy) NetworkReachable reachableBlock;
65 | @property (nonatomic, copy) NetworkUnreachable unreachableBlock;
66 | @property (nonatomic, copy) NetworkReachability reachabilityBlock;
67 |
68 | @property (nonatomic, assign) BOOL reachableOnWWAN;
69 |
70 |
71 | +(instancetype)reachabilityWithHostname:(NSString*)hostname;
72 | // This is identical to the function above, but is here to maintain
73 | //compatibility with Apples original code. (see .m)
74 | +(instancetype)reachabilityWithHostName:(NSString*)hostname;
75 | +(instancetype)reachabilityForInternetConnection;
76 | +(instancetype)reachabilityWithAddress:(void *)hostAddress;
77 | +(instancetype)reachabilityForLocalWiFi;
78 |
79 | -(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
80 |
81 | -(BOOL)startNotifier;
82 | -(void)stopNotifier;
83 |
84 | -(BOOL)isReachable;
85 | -(BOOL)isReachableViaWWAN;
86 | -(BOOL)isReachableViaWiFi;
87 |
88 | // WWAN may be available, but not active until a connection has been established.
89 | // WiFi may require a connection for VPN on Demand.
90 | -(BOOL)isConnectionRequired; // Identical DDG variant.
91 | -(BOOL)connectionRequired; // Apple's routine.
92 | // Dynamic, on demand connection?
93 | -(BOOL)isConnectionOnDemand;
94 | // Is user intervention required?
95 | -(BOOL)isInterventionRequired;
96 |
97 | -(NetworkStatus)currentReachabilityStatus;
98 | -(SCNetworkReachabilityFlags)reachabilityFlags;
99 | -(NSString*)currentReachabilityString;
100 | -(NSString*)currentReachabilityFlags;
101 |
102 | @end
103 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/Reachability.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2011, Tony Million.
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #import "Reachability.h"
29 |
30 | #import
31 | #import
32 | #import
33 | #import
34 | #import
35 | #import
36 |
37 |
38 | NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification";
39 |
40 |
41 | @interface Reachability ()
42 |
43 | @property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef;
44 | @property (nonatomic, strong) dispatch_queue_t reachabilitySerialQueue;
45 | @property (nonatomic, strong) id reachabilityObject;
46 |
47 | -(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags;
48 | -(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags;
49 |
50 | @end
51 |
52 |
53 | static NSString *reachabilityFlags(SCNetworkReachabilityFlags flags)
54 | {
55 | return [NSString stringWithFormat:@"%c%c %c%c%c%c%c%c%c",
56 | #if TARGET_OS_IPHONE
57 | (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
58 | #else
59 | 'X',
60 | #endif
61 | (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
62 | (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
63 | (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
64 | (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
65 | (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
66 | (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
67 | (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
68 | (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-'];
69 | }
70 |
71 | // Start listening for reachability notifications on the current run loop
72 | static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
73 | {
74 | #pragma unused (target)
75 |
76 | Reachability *reachability = ((__bridge Reachability*)info);
77 |
78 | // We probably don't need an autoreleasepool here, as GCD docs state each queue has its own autorelease pool,
79 | // but what the heck eh?
80 | @autoreleasepool
81 | {
82 | [reachability reachabilityChanged:flags];
83 | }
84 | }
85 |
86 |
87 | @implementation Reachability
88 |
89 | #pragma mark - Class Constructor Methods
90 |
91 | +(instancetype)reachabilityWithHostName:(NSString*)hostname
92 | {
93 | return [Reachability reachabilityWithHostname:hostname];
94 | }
95 |
96 | +(instancetype)reachabilityWithHostname:(NSString*)hostname
97 | {
98 | SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]);
99 | if (ref)
100 | {
101 | id reachability = [[self alloc] initWithReachabilityRef:ref];
102 |
103 | return reachability;
104 | }
105 |
106 | return nil;
107 | }
108 |
109 | +(instancetype)reachabilityWithAddress:(void *)hostAddress
110 | {
111 | SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
112 | if (ref)
113 | {
114 | id reachability = [[self alloc] initWithReachabilityRef:ref];
115 |
116 | return reachability;
117 | }
118 |
119 | return nil;
120 | }
121 |
122 | +(instancetype)reachabilityForInternetConnection
123 | {
124 | struct sockaddr_in zeroAddress;
125 | bzero(&zeroAddress, sizeof(zeroAddress));
126 | zeroAddress.sin_len = sizeof(zeroAddress);
127 | zeroAddress.sin_family = AF_INET;
128 |
129 | return [self reachabilityWithAddress:&zeroAddress];
130 | }
131 |
132 | +(instancetype)reachabilityForLocalWiFi
133 | {
134 | struct sockaddr_in localWifiAddress;
135 | bzero(&localWifiAddress, sizeof(localWifiAddress));
136 | localWifiAddress.sin_len = sizeof(localWifiAddress);
137 | localWifiAddress.sin_family = AF_INET;
138 | // IN_LINKLOCALNETNUM is defined in as 169.254.0.0
139 | localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
140 |
141 | return [self reachabilityWithAddress:&localWifiAddress];
142 | }
143 |
144 |
145 | // Initialization methods
146 |
147 | -(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref
148 | {
149 | self = [super init];
150 | if (self != nil)
151 | {
152 | self.reachableOnWWAN = YES;
153 | self.reachabilityRef = ref;
154 |
155 | // We need to create a serial queue.
156 | // We allocate this once for the lifetime of the notifier.
157 |
158 | self.reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL);
159 | }
160 |
161 | return self;
162 | }
163 |
164 | -(void)dealloc
165 | {
166 | [self stopNotifier];
167 |
168 | if(self.reachabilityRef)
169 | {
170 | CFRelease(self.reachabilityRef);
171 | self.reachabilityRef = nil;
172 | }
173 |
174 | self.reachableBlock = nil;
175 | self.unreachableBlock = nil;
176 | self.reachabilityBlock = nil;
177 | self.reachabilitySerialQueue = nil;
178 | }
179 |
180 | #pragma mark - Notifier Methods
181 |
182 | // Notifier
183 | // NOTE: This uses GCD to trigger the blocks - they *WILL NOT* be called on THE MAIN THREAD
184 | // - In other words DO NOT DO ANY UI UPDATES IN THE BLOCKS.
185 | // INSTEAD USE dispatch_async(dispatch_get_main_queue(), ^{UISTUFF}) (or dispatch_sync if you want)
186 |
187 | -(BOOL)startNotifier
188 | {
189 | // allow start notifier to be called multiple times
190 | if(self.reachabilityObject && (self.reachabilityObject == self))
191 | {
192 | return YES;
193 | }
194 |
195 |
196 | SCNetworkReachabilityContext context = { 0, NULL, NULL, NULL, NULL };
197 | context.info = (__bridge void *)self;
198 |
199 | if(SCNetworkReachabilitySetCallback(self.reachabilityRef, TMReachabilityCallback, &context))
200 | {
201 | // Set it as our reachability queue, which will retain the queue
202 | if(SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue))
203 | {
204 | // this should do a retain on ourself, so as long as we're in notifier mode we shouldn't disappear out from under ourselves
205 | // woah
206 | self.reachabilityObject = self;
207 | return YES;
208 | }
209 | else
210 | {
211 | #ifdef DEBUG
212 | NSLog(@"SCNetworkReachabilitySetDispatchQueue() failed: %s", SCErrorString(SCError()));
213 | #endif
214 |
215 | // UH OH - FAILURE - stop any callbacks!
216 | SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
217 | }
218 | }
219 | else
220 | {
221 | #ifdef DEBUG
222 | NSLog(@"SCNetworkReachabilitySetCallback() failed: %s", SCErrorString(SCError()));
223 | #endif
224 | }
225 |
226 | // if we get here we fail at the internet
227 | self.reachabilityObject = nil;
228 | return NO;
229 | }
230 |
231 | -(void)stopNotifier
232 | {
233 | // First stop, any callbacks!
234 | SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
235 |
236 | // Unregister target from the GCD serial dispatch queue.
237 | SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, NULL);
238 |
239 | self.reachabilityObject = nil;
240 | }
241 |
242 | #pragma mark - reachability tests
243 |
244 | // This is for the case where you flick the airplane mode;
245 | // you end up getting something like this:
246 | //Reachability: WR ct-----
247 | //Reachability: -- -------
248 | //Reachability: WR ct-----
249 | //Reachability: -- -------
250 | // We treat this as 4 UNREACHABLE triggers - really apple should do better than this
251 |
252 | #define testcase (kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection)
253 |
254 | -(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags
255 | {
256 | BOOL connectionUP = YES;
257 |
258 | if(!(flags & kSCNetworkReachabilityFlagsReachable))
259 | connectionUP = NO;
260 |
261 | if( (flags & testcase) == testcase )
262 | connectionUP = NO;
263 |
264 | #if TARGET_OS_IPHONE
265 | if(flags & kSCNetworkReachabilityFlagsIsWWAN)
266 | {
267 | // We're on 3G.
268 | if(!self.reachableOnWWAN)
269 | {
270 | // We don't want to connect when on 3G.
271 | connectionUP = NO;
272 | }
273 | }
274 | #endif
275 |
276 | return connectionUP;
277 | }
278 |
279 | -(BOOL)isReachable
280 | {
281 | SCNetworkReachabilityFlags flags;
282 |
283 | if(!SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
284 | return NO;
285 |
286 | return [self isReachableWithFlags:flags];
287 | }
288 |
289 | -(BOOL)isReachableViaWWAN
290 | {
291 | #if TARGET_OS_IPHONE
292 |
293 | SCNetworkReachabilityFlags flags = 0;
294 |
295 | if(SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
296 | {
297 | // Check we're REACHABLE
298 | if(flags & kSCNetworkReachabilityFlagsReachable)
299 | {
300 | // Now, check we're on WWAN
301 | if(flags & kSCNetworkReachabilityFlagsIsWWAN)
302 | {
303 | return YES;
304 | }
305 | }
306 | }
307 | #endif
308 |
309 | return NO;
310 | }
311 |
312 | -(BOOL)isReachableViaWiFi
313 | {
314 | SCNetworkReachabilityFlags flags = 0;
315 |
316 | if(SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
317 | {
318 | // Check we're reachable
319 | if((flags & kSCNetworkReachabilityFlagsReachable))
320 | {
321 | #if TARGET_OS_IPHONE
322 | // Check we're NOT on WWAN
323 | if((flags & kSCNetworkReachabilityFlagsIsWWAN))
324 | {
325 | return NO;
326 | }
327 | #endif
328 | return YES;
329 | }
330 | }
331 |
332 | return NO;
333 | }
334 |
335 |
336 | // WWAN may be available, but not active until a connection has been established.
337 | // WiFi may require a connection for VPN on Demand.
338 | -(BOOL)isConnectionRequired
339 | {
340 | return [self connectionRequired];
341 | }
342 |
343 | -(BOOL)connectionRequired
344 | {
345 | SCNetworkReachabilityFlags flags;
346 |
347 | if(SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
348 | {
349 | return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
350 | }
351 |
352 | return NO;
353 | }
354 |
355 | // Dynamic, on demand connection?
356 | -(BOOL)isConnectionOnDemand
357 | {
358 | SCNetworkReachabilityFlags flags;
359 |
360 | if (SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
361 | {
362 | return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) &&
363 | (flags & (kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand)));
364 | }
365 |
366 | return NO;
367 | }
368 |
369 | // Is user intervention required?
370 | -(BOOL)isInterventionRequired
371 | {
372 | SCNetworkReachabilityFlags flags;
373 |
374 | if (SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
375 | {
376 | return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) &&
377 | (flags & kSCNetworkReachabilityFlagsInterventionRequired));
378 | }
379 |
380 | return NO;
381 | }
382 |
383 |
384 | #pragma mark - reachability status stuff
385 |
386 | -(NetworkStatus)currentReachabilityStatus
387 | {
388 | if([self isReachable])
389 | {
390 | if([self isReachableViaWiFi])
391 | return ReachableViaWiFi;
392 |
393 | #if TARGET_OS_IPHONE
394 | return ReachableViaWWAN;
395 | #endif
396 | }
397 |
398 | return NotReachable;
399 | }
400 |
401 | -(SCNetworkReachabilityFlags)reachabilityFlags
402 | {
403 | SCNetworkReachabilityFlags flags = 0;
404 |
405 | if(SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
406 | {
407 | return flags;
408 | }
409 |
410 | return 0;
411 | }
412 |
413 | -(NSString*)currentReachabilityString
414 | {
415 | NetworkStatus temp = [self currentReachabilityStatus];
416 |
417 | if(temp == ReachableViaWWAN)
418 | {
419 | // Updated for the fact that we have CDMA phones now!
420 | return NSLocalizedString(@"Cellular", @"");
421 | }
422 | if (temp == ReachableViaWiFi)
423 | {
424 | return NSLocalizedString(@"WiFi", @"");
425 | }
426 |
427 | return NSLocalizedString(@"No Connection", @"");
428 | }
429 |
430 | -(NSString*)currentReachabilityFlags
431 | {
432 | return reachabilityFlags([self reachabilityFlags]);
433 | }
434 |
435 | #pragma mark - Callback function calls this method
436 |
437 | -(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags
438 | {
439 | if([self isReachableWithFlags:flags])
440 | {
441 | if(self.reachableBlock)
442 | {
443 | self.reachableBlock(self);
444 | }
445 | }
446 | else
447 | {
448 | if(self.unreachableBlock)
449 | {
450 | self.unreachableBlock(self);
451 | }
452 | }
453 |
454 | if(self.reachabilityBlock)
455 | {
456 | self.reachabilityBlock(self, flags);
457 | }
458 |
459 | // this makes sure the change notification happens on the MAIN THREAD
460 | dispatch_async(dispatch_get_main_queue(), ^{
461 | [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification
462 | object:self];
463 | });
464 | }
465 |
466 | #pragma mark - Debug Description
467 |
468 | - (NSString *) description
469 | {
470 | NSString *description = [NSString stringWithFormat:@"<%@: %#x (%@)>",
471 | NSStringFromClass([self class]), (unsigned int) self, [self currentReachabilityFlags]];
472 | return description;
473 | }
474 |
475 | @end
476 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/TodayViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // TodayViewController.h
3 | // ZYDMonitor
4 | //
5 | // Created by 朱耀东 on 15/11/16.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface TodayViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/TodayViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // TodayViewController.m
3 | // ZYDMonitor
4 | //
5 | // Created by 朱耀东 on 15/11/16.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import "TodayViewController.h"
10 | #import
11 |
12 | #import
13 | #import
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #import "WMGaugeView.h"
20 | #import "Reachability.h"
21 |
22 | @interface TodayViewController ()
23 | @property (weak, nonatomic) IBOutlet UILabel *menoryLab;
24 | @property (weak, nonatomic) IBOutlet UILabel *diskLab;
25 |
26 | @property (weak, nonatomic) IBOutlet UILabel *topLiuLiang;
27 | @property (weak, nonatomic) IBOutlet UILabel *downLiuLiang;
28 | @property (weak, nonatomic) IBOutlet UILabel *cpuLab;
29 | @property (weak, nonatomic) IBOutlet WMGaugeView *guanGeView;
30 | @property (weak, nonatomic) IBOutlet UILabel *memoryPreLab;
31 |
32 | @property (assign, nonatomic) float preWWAN_R;
33 |
34 | @property (assign, nonatomic) float preWWAN_S;
35 |
36 | @property (assign, nonatomic) float preWifi_R;
37 |
38 | @property (assign, nonatomic) float preWifi_S;
39 |
40 | @property (strong, nonatomic) NSTimer *timer;
41 |
42 | @property (assign, nonatomic) int preRef;
43 |
44 | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *conR;
45 |
46 | @property (weak, nonatomic) IBOutlet NSLayoutConstraint *conRR;
47 | @end
48 |
49 | @implementation TodayViewController
50 |
51 | - (void)viewDidLoad {
52 | [super viewDidLoad];
53 |
54 |
55 | CGFloat SW = [UIScreen mainScreen].bounds.size.width;
56 |
57 | if (SW == 320) {
58 | self.conR.constant = -10;
59 | }else if (SW == 375) {
60 | self.conRR.constant = 25;
61 | self.conR.constant = 10;
62 | }else if (SW == 414) {
63 | self.conRR.constant = 45;
64 | self.conR.constant = 20;
65 | }
66 |
67 | // self.flag = NO;
68 |
69 | self.preferredContentSize = CGSizeMake(320, 150);
70 |
71 | [self currentLiuLiang];
72 |
73 | [self setAppearance];
74 |
75 | [self refreshV];
76 |
77 | // self.guanGeView.value = 0.0;
78 |
79 | float availableMemory = [self availableMemory];
80 | self.menoryLab.text = [NSString stringWithFormat:@"%.0f MB", availableMemory];
81 |
82 | float allMemory = [self getTotalMemorySize];
83 | float memoryPre = (1-availableMemory/allMemory)*100;
84 |
85 | self.guanGeView.value = memoryPre;
86 | // self.flag = YES;
87 |
88 | NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(refreshV) userInfo:nil repeats:YES];
89 | self.timer = timer;
90 |
91 | // CADisplayLink* link = [CADisplayLink displayLinkWithTarget:self selector:@selector(refreshV)];
92 | // [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
93 | // link.frameInterval = 60;
94 | }
95 |
96 | - (void)viewWillAppear:(BOOL)animated {
97 | [super viewWillAppear:animated];
98 |
99 | // NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(refreshV) userInfo:nil repeats:YES];
100 | // self.timer = timer;
101 | }
102 |
103 | - (void)viewWillDisappear:(BOOL)animated {
104 | NSLog(@"disOver");
105 | [self.timer invalidate];
106 | self.timer = nil;
107 | [super viewWillDisappear:animated];
108 | }
109 |
110 | - (void)dealloc {
111 | NSLog(@"ove");
112 | if (self.timer.isValid) {
113 | [self.timer invalidate];
114 | self.timer = nil;
115 | }
116 | }
117 |
118 | - (void)setAppearance {
119 | self.guanGeView.maxValue = 100.0;
120 | self.guanGeView.scaleDivisions = 10;
121 | self.guanGeView.scaleSubdivisions = 5;
122 | self.guanGeView.scaleStartAngle = 60;
123 | self.guanGeView.scaleEndAngle = 300;
124 | self.guanGeView.innerBackgroundStyle = WMGaugeViewInnerBackgroundStyleFlat;
125 | self.guanGeView.showScaleShadow = NO;
126 | // self.guanGeView.scaleFont = [UIFont fontWithName:@"AvenirNext-UltraLight" size:0.065];
127 | self.guanGeView.scalesubdivisionsaligment = WMGaugeViewSubdivisionsAlignmentCenter;
128 | self.guanGeView.scaleSubdivisionsWidth = 0.002;
129 | self.guanGeView.scaleSubdivisionsLength = 0.04;
130 | self.guanGeView.scaleDivisionsWidth = 0.007;
131 | self.guanGeView.scaleDivisionsLength = 0.07;
132 | self.guanGeView.needleStyle = WMGaugeViewNeedleStyleFlatThin;
133 | self.guanGeView.needleWidth = 0.012;
134 | self.guanGeView.needleHeight = 0.4;
135 | self.guanGeView.needleScrewStyle = WMGaugeViewNeedleScrewStylePlain;
136 | self.guanGeView.needleScrewRadius = 0.05;
137 | }
138 |
139 | - (void)refreshV {
140 | // NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.gsMonitorDemo"];
141 | // float availableMemory = [userDefaults floatForKey:@"group.availableMemory"];
142 |
143 | // 内存、存储
144 | float availableMemory = [self availableMemory];
145 | self.menoryLab.text = [NSString stringWithFormat:@"%.0f MB", availableMemory];
146 |
147 | float allMemory = [self getTotalMemorySize];
148 | float memoryPre = (1-availableMemory/allMemory)*100;
149 | self.memoryPreLab.text = [NSString stringWithFormat:@"%.2f %%", memoryPre];
150 | if (self.preRef % 2 == 0) {
151 | NSLog(@"%f", memoryPre);
152 | self.guanGeView.value = memoryPre;
153 | if (self.preRef == 100) {
154 | self.preRef = 0;
155 | }
156 | }
157 | self.preRef ++;
158 |
159 | float availableDiskSize = [self getAvailableDiskSize];
160 | self.diskLab.text = [NSString stringWithFormat:@"%.2f GB", availableDiskSize / 1024.0];
161 |
162 | // 上行、下行流量
163 | Reachability *reachability = [Reachability reachabilityWithHostName:@"hha"];
164 | if (reachability.currentReachabilityStatus == ReachableViaWiFi) {
165 | float wifiS_preSecond = [[self getDataCounters][0] floatValue] - self.preWifi_S;
166 | float wifiR_preSecond = [[self getDataCounters][1] floatValue] - self.preWifi_R;
167 | self.topLiuLiang.text = [NSString stringWithFormat:@"%.0f KB/s", wifiS_preSecond];
168 | self.downLiuLiang.text = [NSString stringWithFormat:@"%.0f KB/s", wifiR_preSecond];
169 | }else if(reachability.currentReachabilityStatus == ReachableViaWWAN) {
170 | float wwanS_preSecond = [[self getDataCounters][2] floatValue] - self.preWWAN_S;
171 | float wwanR_preSecond = [[self getDataCounters][3] floatValue] - self.preWWAN_R;
172 | self.topLiuLiang.text = [NSString stringWithFormat:@"%.0f KB/s", wwanS_preSecond];
173 | self.downLiuLiang.text = [NSString stringWithFormat:@"%.0f KB/s", wwanR_preSecond];
174 | }else {
175 | }
176 |
177 | [self currentLiuLiang];
178 |
179 | float cpuUsage = [self cpu_usage];
180 | self.cpuLab.text = [NSString stringWithFormat:@"%.1f%%", cpuUsage];
181 | }
182 |
183 | // 赋值当前流量
184 | - (void)currentLiuLiang {
185 | NSNumber *wifiSendNumber = [self getDataCounters][0];
186 | float wifiS = [wifiSendNumber floatValue];
187 | self.preWifi_S = wifiS;
188 |
189 | NSNumber *wifiReceived = [self getDataCounters][1];
190 | float wifiR = [wifiReceived floatValue];
191 | self.preWifi_R = wifiR;
192 |
193 | NSNumber *wwanSendNumber = [self getDataCounters][2];
194 | float wwanS = [wwanSendNumber floatValue];
195 | self.preWWAN_S = wwanS;
196 |
197 | NSNumber *wwanReceived = [self getDataCounters][3];
198 | float wwanR = [wwanReceived floatValue];
199 | self.preWWAN_R = wwanR;
200 | }
201 |
202 | // 获取当前设备可用内存(单位:MB)
203 | - (float)availableMemory
204 | {
205 | vm_statistics_data_t vmStats;
206 | mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
207 | kern_return_t kernReturn = host_statistics(mach_host_self(),
208 | HOST_VM_INFO,
209 | (host_info_t)&vmStats,
210 | &infoCount);
211 |
212 | if (kernReturn != KERN_SUCCESS) {
213 | return NSNotFound;
214 | }
215 |
216 | return ((vm_page_size *vmStats.free_count) / 1024.0) / 1024.0;
217 | }
218 |
219 | // 获取总内存大小
220 | - (float)getTotalMemorySize
221 | {
222 | return [NSProcessInfo processInfo].physicalMemory / 1024.0 / 1024.0;
223 | }
224 |
225 | // 获取当前设备可用存储(单位:MB)
226 | -(float)getAvailableDiskSize
227 | {
228 | struct statfs buf;
229 | unsigned long long freeSpace = -1;
230 | if (statfs("/var", &buf) >= 0)
231 | {
232 | freeSpace = (unsigned long long)(buf.f_bsize * buf.f_bavail);
233 | }
234 | return freeSpace / 1024.0 / 1024.0;
235 | }
236 |
237 | // 上行、下行流量
238 | - (NSArray *)getDataCounters
239 | {
240 | BOOL success;
241 | struct ifaddrs *addrs;
242 | struct ifaddrs *cursor;
243 | struct if_data *networkStatisc;
244 | long WiFiSent = 0;
245 | long WiFiReceived = 0;
246 | long WWANSent = 0;
247 | long WWANReceived = 0;
248 | NSString *name=[[NSString alloc]init];
249 | success = getifaddrs(&addrs) == 0;
250 | if (success)
251 | {
252 | cursor = addrs;
253 | while (cursor != NULL)
254 | {
255 | name=[NSString stringWithFormat:@"%s",cursor->ifa_name];
256 | //NSLog(@"ifa_name %s == %@\n", cursor->ifa_name,name);
257 | // names of interfaces: en0 is WiFi ,pdp_ip0 is WWAN
258 | if (cursor->ifa_addr->sa_family == AF_LINK)
259 | {
260 | if ([name hasPrefix:@"en"])
261 | {
262 | networkStatisc = (struct if_data *) cursor->ifa_data;
263 | WiFiSent+=networkStatisc->ifi_obytes;
264 | WiFiReceived+=networkStatisc->ifi_ibytes;
265 | //NSLog(@"WiFiSent %d ==%d",WiFiSent,networkStatisc->ifi_obytes);
266 | //NSLog(@"WiFiReceived %d ==%d",WiFiReceived,networkStatisc->ifi_ibytes);
267 | }
268 | if ([name hasPrefix:@"pdp_ip"])
269 | {
270 | networkStatisc = (struct if_data *) cursor->ifa_data;
271 | WWANSent+=networkStatisc->ifi_obytes;
272 | WWANReceived+=networkStatisc->ifi_ibytes;
273 | //NSLog(@"WWANSent %d ==%d",WWANSent,networkStatisc->ifi_obytes);
274 | //NSLog(@"WWANReceived %d ==%d",WWANReceived,networkStatisc->ifi_ibytes);
275 | }
276 | }
277 | cursor = cursor->ifa_next;
278 | }
279 | freeifaddrs(addrs);
280 | }
281 | return [NSArray arrayWithObjects:[NSNumber numberWithInt:WiFiSent/1024], [NSNumber numberWithInt:WiFiReceived/1024],[NSNumber numberWithInt:WWANSent/1024],[NSNumber numberWithInt:WWANReceived/1024], nil];
282 | }
283 |
284 | // cpu
285 | -(float) cpu_usage
286 | {
287 | kern_return_t kr;
288 | task_info_data_t tinfo;
289 | mach_msg_type_number_t task_info_count;
290 |
291 | task_info_count = TASK_INFO_MAX;
292 | kr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)tinfo, &task_info_count);
293 | if (kr != KERN_SUCCESS) {
294 | return -1;
295 | }
296 |
297 | task_basic_info_t basic_info;
298 | thread_array_t thread_list;
299 | mach_msg_type_number_t thread_count;
300 |
301 | thread_info_data_t thinfo;
302 | mach_msg_type_number_t thread_info_count;
303 |
304 | thread_basic_info_t basic_info_th;
305 | uint32_t stat_thread = 0; // Mach threads
306 |
307 | basic_info = (task_basic_info_t)tinfo;
308 |
309 | // get threads in the task
310 | kr = task_threads(mach_task_self(), &thread_list, &thread_count);
311 | if (kr != KERN_SUCCESS) {
312 | return -1;
313 | }
314 | if (thread_count > 0)
315 | stat_thread += thread_count;
316 |
317 | long tot_sec = 0;
318 | long tot_usec = 0;
319 | float tot_cpu = 0;
320 | int j;
321 |
322 | for (j = 0; j < thread_count; j++)
323 | {
324 | thread_info_count = THREAD_INFO_MAX;
325 | kr = thread_info(thread_list[j], THREAD_BASIC_INFO,
326 | (thread_info_t)thinfo, &thread_info_count);
327 | if (kr != KERN_SUCCESS) {
328 | return -1;
329 | }
330 |
331 | basic_info_th = (thread_basic_info_t)thinfo;
332 |
333 | if (!(basic_info_th->flags & TH_FLAGS_IDLE)) {
334 | tot_sec = tot_sec + basic_info_th->user_time.seconds + basic_info_th->system_time.seconds;
335 | tot_usec = tot_usec + basic_info_th->system_time.microseconds + basic_info_th->system_time.microseconds;
336 | tot_cpu = tot_cpu + basic_info_th->cpu_usage / (float)TH_USAGE_SCALE * 100.0;
337 | }
338 |
339 | } // for each thread
340 |
341 | kr = vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_t));
342 | assert(kr == KERN_SUCCESS);
343 |
344 | return tot_cpu;
345 | }
346 |
347 | - (void)didReceiveMemoryWarning {
348 | [super didReceiveMemoryWarning];
349 | // Dispose of any resources that can be recreated.
350 | }
351 |
352 | - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
353 | // Perform any setup necessary in order to update the view.
354 |
355 | // If an error is encountered, use NCUpdateResultFailed
356 | // If there's no update required, use NCUpdateResultNoData
357 | // If there's an update, use NCUpdateResultNewData
358 |
359 | completionHandler(NCUpdateResultNewData);
360 | }
361 |
362 | @end
363 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/WMGaugeView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * WMGaugeView.h
3 | *
4 | * Copyright (C) 2014 William Markezana
5 | *
6 | */
7 |
8 | #import
9 |
10 | typedef enum
11 | {
12 | WMGaugeViewSubdivisionsAlignmentTop,
13 | WMGaugeViewSubdivisionsAlignmentCenter,
14 | WMGaugeViewSubdivisionsAlignmentBottom
15 | }
16 | WMGaugeViewSubdivisionsAlignment;
17 |
18 | typedef enum
19 | {
20 | WMGaugeViewNeedleStyle3D,
21 | WMGaugeViewNeedleStyleFlatThin
22 | }
23 | WMGaugeViewNeedleStyle;
24 |
25 | typedef enum
26 | {
27 | WMGaugeViewNeedleScrewStyleGradient,
28 | WMGaugeViewNeedleScrewStylePlain
29 | }
30 | WMGaugeViewNeedleScrewStyle;
31 |
32 | typedef enum
33 | {
34 | WMGaugeViewInnerBackgroundStyleGradient,
35 | WMGaugeViewInnerBackgroundStyleFlat
36 | }
37 | WMGaugeViewInnerBackgroundStyle;
38 |
39 | @interface WMGaugeView : UIView
40 |
41 | @property (nonatomic) bool showInnerBackground;
42 | @property (nonatomic) bool showInnerRim;
43 | @property (nonatomic) CGFloat innerRimWidth;
44 | @property (nonatomic) CGFloat innerRimBorderWidth;
45 | @property (nonatomic) WMGaugeViewInnerBackgroundStyle innerBackgroundStyle;
46 |
47 | @property (nonatomic) CGFloat needleWidth;
48 | @property (nonatomic) CGFloat needleHeight;
49 | @property (nonatomic) CGFloat needleScrewRadius;
50 | @property (nonatomic) WMGaugeViewNeedleStyle needleStyle;
51 | @property (nonatomic) WMGaugeViewNeedleScrewStyle needleScrewStyle;
52 |
53 | @property (nonatomic) CGFloat scalePosition;
54 | @property (nonatomic) CGFloat scaleStartAngle;
55 | @property (nonatomic) CGFloat scaleEndAngle;
56 | @property (nonatomic) CGFloat scaleDivisions;
57 | @property (nonatomic) CGFloat scaleSubdivisions;
58 | @property (nonatomic) bool showScaleShadow;
59 | @property (nonatomic) WMGaugeViewSubdivisionsAlignment scalesubdivisionsaligment;
60 | @property (nonatomic) CGFloat scaleDivisionsLength;
61 | @property (nonatomic) CGFloat scaleDivisionsWidth;
62 | @property (nonatomic) CGFloat scaleSubdivisionsLength;
63 | @property (nonatomic) CGFloat scaleSubdivisionsWidth;
64 |
65 | @property (nonatomic, strong) UIColor *scaleDivisionColor;
66 | @property (nonatomic, strong) UIColor *scaleSubDivisionColor;
67 |
68 | @property (nonatomic, strong) UIFont *scaleFont;
69 |
70 | @property (nonatomic) CGFloat rangeLabelsWidth;
71 |
72 | @property (nonatomic) float value;
73 | @property (nonatomic) float minValue;
74 | @property (nonatomic) float maxValue;
75 |
76 | @property (nonatomic) bool showRangeLabels;
77 | @property (nonatomic) CGFloat rangeLabelsFontKerning;
78 | @property (nonatomic, strong) NSArray *rangeValues;
79 | @property (nonatomic, strong) NSArray *rangeColors;
80 | @property (nonatomic, strong) NSArray *rangeLabels;
81 |
82 | @property (nonatomic, strong) NSString *unitOfMeasurement;
83 | @property (nonatomic) bool showUnitOfMeasurement;
84 |
85 | - (void)setValue:(float)value animated:(BOOL)animated;
86 |
87 | @end
88 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/WMGaugeView.m:
--------------------------------------------------------------------------------
1 | /*
2 | * WMGaugeView.h
3 | *
4 | * Copyright (C) 2014 William Markezana
5 | *
6 | */
7 |
8 | #import "WMGaugeView.h"
9 |
10 | #define DEGREES_TO_RADIANS(degrees) (degrees) / 180.0 * M_PI
11 |
12 | #define RGB(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0]
13 | #define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a/255.0]
14 | #define CGRGB(r,g,b) RGB(r,g,b).CGColor
15 | #define iCGRGB(r,g,b) (id)CGRGB(r,g,b)
16 | #define CGRGBA(r,g,b,a) RGBA(r,g,b,a).CGColor
17 | #define iCGRGBA(r,g,b,a) (id)CGRGBA(r,g,b,a)
18 |
19 | @implementation WMGaugeView
20 | {
21 | CGRect fullRect;
22 | CGRect innerRimRect;
23 | CGRect innerRimBorderRect;
24 | CGRect faceRect;
25 | CGRect rangeLabelsRect;
26 | CGRect scaleRect;
27 | CGPoint center;
28 | CGFloat scaleRotation;
29 | CGFloat divisionValue;
30 | CGFloat subdivisionValue;
31 | CGFloat subdivisionAngle;
32 | double currentValue;
33 | double needleAcceleration;
34 | double needleVelocity;
35 | NSTimeInterval needleLastMoved;
36 | UIImage *background;
37 | }
38 |
39 | - (id)initWithFrame:(CGRect)frame
40 | {
41 | self = [super initWithFrame:frame];
42 | if (self)
43 | {
44 | [self initialize];
45 | }
46 | return self;
47 | }
48 |
49 | - (void)awakeFromNib
50 | {
51 | [self initialize];
52 | }
53 |
54 | - (void)initialize;
55 | {
56 | _showInnerRim = NO;
57 | _showInnerBackground = YES;
58 | _innerRimWidth = 0.05;
59 | _innerRimBorderWidth = 0.005;
60 | _innerBackgroundStyle = WMGaugeViewInnerBackgroundStyleGradient;
61 |
62 | _needleWidth = 0.035;
63 | _needleHeight = 0.34;
64 | _needleScrewRadius = 0.04;
65 | _needleStyle = WMGaugeViewNeedleStyle3D;
66 | _needleScrewStyle = WMGaugeViewNeedleScrewStyleGradient;
67 |
68 | _scalePosition = 0.025;
69 | _scaleStartAngle = 30.0;
70 | _scaleEndAngle = 330.0;
71 | _scaleDivisions = 12.0;
72 | _scaleSubdivisions = 10.0;
73 | _showScaleShadow = YES;
74 | _scalesubdivisionsaligment = WMGaugeViewSubdivisionsAlignmentTop;
75 | _scaleDivisionsLength = 0.045;
76 | _scaleDivisionsWidth = 0.01;
77 | _scaleSubdivisionsLength = 0.015;
78 | _scaleSubdivisionsWidth = 0.01;
79 |
80 | _value = 0.0;
81 | _minValue = 0.0;
82 | _maxValue = 240.0;
83 | currentValue = 0.0;
84 |
85 | needleVelocity = 0.0;
86 | needleAcceleration = 0.0;
87 | needleLastMoved = -1;
88 |
89 | background = nil;
90 |
91 | _showRangeLabels = NO;
92 | _rangeLabelsWidth = 0.05;
93 | _rangeLabelsFontKerning = 1.0;
94 | _rangeValues = nil;
95 | _rangeColors = nil;
96 | _rangeLabels = nil;
97 |
98 | // _scaleDivisionColor = RGB(68, 84, 105);
99 | _scaleDivisionColor = [UIColor whiteColor];
100 | _scaleSubDivisionColor = RGB(217, 217, 217);
101 | // [UIColor colorWithRed:217/255.0 green:217/255.0 blue:217/255.0 alpha:1]
102 |
103 | _scaleFont = nil;
104 |
105 | _unitOfMeasurement = @"";
106 | _showUnitOfMeasurement = NO;
107 |
108 | [self initDrawingRects];
109 | [self initScale];
110 | }
111 |
112 | - (void)initDrawingRects
113 | {
114 | center = CGPointMake(0.5, 0.5);
115 | fullRect = CGRectMake(0.0, 0.0, 1.0, 1.0);
116 |
117 | _innerRimBorderWidth = _showInnerRim?_innerRimBorderWidth:0.0;
118 | _innerRimWidth = _showInnerRim?_innerRimWidth:0.0;
119 |
120 | innerRimRect = fullRect;
121 | innerRimBorderRect = CGRectMake(innerRimRect.origin.x + _innerRimBorderWidth,
122 | innerRimRect.origin.y + _innerRimBorderWidth,
123 | innerRimRect.size.width - 2 * _innerRimBorderWidth,
124 | innerRimRect.size.height - 2 * _innerRimBorderWidth);
125 | faceRect = CGRectMake(innerRimRect.origin.x + _innerRimWidth,
126 | innerRimRect.origin.y + _innerRimWidth,
127 | innerRimRect.size.width - 2 * _innerRimWidth,
128 | innerRimRect.size.height - 2 * _innerRimWidth);
129 | rangeLabelsRect = CGRectMake(faceRect.origin.x + (_showRangeLabels ? _rangeLabelsWidth : 0.0),
130 | faceRect.origin.y + (_showRangeLabels ? _rangeLabelsWidth : 0.0),
131 | faceRect.size.width - 2 * (_showRangeLabels ? _rangeLabelsWidth : 0.0),
132 | faceRect.size.height - 2 * (_showRangeLabels ? _rangeLabelsWidth : 0.0));
133 | scaleRect = CGRectMake(rangeLabelsRect.origin.x + _scalePosition,
134 | rangeLabelsRect.origin.y + _scalePosition,
135 | rangeLabelsRect.size.width - 2 * _scalePosition,
136 | rangeLabelsRect.size.height - 2 * _scalePosition);
137 | }
138 |
139 | - (void)rotateContext:(CGContextRef)context fromCenter:(CGPoint)center_ withAngle:(CGFloat)angle
140 | {
141 | CGContextTranslateCTM(context, center_.x, center_.y);
142 | CGContextRotateCTM(context, angle);
143 | CGContextTranslateCTM(context, -center_.x, -center_.y);
144 | }
145 |
146 | - (void)drawRect:(CGRect)rect
147 | {
148 | [self computeCurrentValue];
149 |
150 | if (background == nil)
151 | {
152 | UIGraphicsBeginImageContextWithOptions(rect.size, NO, [UIScreen mainScreen].scale);
153 | CGContextRef context = UIGraphicsGetCurrentContext();
154 | CGContextScaleCTM(context, rect.size.width , rect.size.height);
155 | [self drawGauge:context];
156 | background = UIGraphicsGetImageFromCurrentImageContext();
157 | UIGraphicsEndImageContext();
158 | }
159 |
160 | [background drawInRect:rect];
161 |
162 | CGContextRef context = UIGraphicsGetCurrentContext();
163 | CGContextScaleCTM(context, rect.size.width , rect.size.height);
164 |
165 | [self drawNeedle:context];
166 | }
167 |
168 | - (void)drawGauge:(CGContextRef)context
169 | {
170 | [self drawRim:context];
171 | if (_showInnerBackground)
172 | [self drawFace:context];
173 | if (_showUnitOfMeasurement)
174 | [self drawText:context];
175 | [self drawScale:context];
176 | if (_showRangeLabels)
177 | [self drawRangeLabels:context];
178 | }
179 |
180 | - (void)drawRim:(CGContextRef)context
181 | {
182 |
183 | }
184 |
185 | - (void)drawFace:(CGContextRef)context
186 | {
187 | switch (_innerBackgroundStyle)
188 | {
189 | case WMGaugeViewInnerBackgroundStyleGradient:
190 | {
191 | // Default Face
192 | CGColorSpaceRef baseSpace = CGColorSpaceCreateDeviceRGB();
193 | CGGradientRef gradient = CGGradientCreateWithColors(baseSpace, (CFArrayRef)@[iCGRGB(96, 96, 96), iCGRGB(68, 68, 68), iCGRGB(32, 32, 32)], (const CGFloat[]){0.35, 0.96, 0.99});
194 | CGColorSpaceRelease(baseSpace), baseSpace = NULL;
195 | CGContextAddEllipseInRect(context, faceRect);
196 | CGContextClip(context);
197 | CGContextDrawRadialGradient(context, gradient, center, 0, center, faceRect.size.width / 2.0, kCGGradientDrawsAfterEndLocation);
198 | CGGradientRelease(gradient), gradient = NULL;
199 |
200 | // Shadow
201 | baseSpace = CGColorSpaceCreateDeviceRGB();
202 | gradient = CGGradientCreateWithColors(baseSpace, (CFArrayRef)@[iCGRGBA(40, 96, 170, 60), iCGRGBA(15, 34, 98, 80), iCGRGBA(0, 0, 0, 120), iCGRGBA(0, 0, 0, 140)], (const CGFloat[]){0.60, 0.85, 0.96, 0.99});
203 | CGColorSpaceRelease(baseSpace), baseSpace = NULL;
204 | CGContextAddEllipseInRect(context, faceRect);
205 | CGContextClip(context);
206 | CGContextDrawRadialGradient(context, gradient, center, 0, center, faceRect.size.width / 2.0, kCGGradientDrawsAfterEndLocation);
207 | CGGradientRelease(gradient), gradient = NULL;
208 |
209 | // Border
210 | CGContextSetLineWidth(context, 0.005);
211 | CGContextSetStrokeColorWithColor(context, CGRGBA(81, 84, 89, 160));
212 | CGContextAddEllipseInRect(context, faceRect);
213 | CGContextStrokePath(context);
214 | }
215 | break;
216 |
217 | case WMGaugeViewInnerBackgroundStyleFlat:
218 | {
219 | #define EXTERNAL_RING_RADIUS 0.24
220 | #define INTERNAL_RING_RADIUS 0.1
221 |
222 | CGContextAddEllipseInRect(context, CGRectMake(center.x - EXTERNAL_RING_RADIUS, center.y - EXTERNAL_RING_RADIUS, EXTERNAL_RING_RADIUS * 2.0, EXTERNAL_RING_RADIUS * 2.0));
223 | CGContextSetFillColorWithColor(context, [[UIColor colorWithWhite:0 alpha:0.2] CGColor]);
224 | CGContextFillPath(context);
225 |
226 |
227 | CGContextAddEllipseInRect(context, CGRectMake(center.x - INTERNAL_RING_RADIUS, center.y - INTERNAL_RING_RADIUS, INTERNAL_RING_RADIUS * 2.0, INTERNAL_RING_RADIUS * 2.0));
228 | CGContextSetFillColorWithColor(context, [[UIColor colorWithWhite:0 alpha:0.1] CGColor]);
229 | CGContextFillPath(context);
230 | }
231 | break;
232 |
233 | default:
234 | break;
235 | }
236 | }
237 |
238 | - (void)drawText:(CGContextRef)context
239 | {
240 | CGContextSetShadow(context, CGSizeMake(0.05, 0.05), 2.0);
241 | UIFont* font = [UIFont fontWithName:@"Helvetica" size:0.04];
242 | NSDictionary* stringAttrs = @{ NSFontAttributeName : font, NSForegroundColorAttributeName : [UIColor whiteColor] };
243 | NSAttributedString* attrStr = [[NSAttributedString alloc] initWithString:_unitOfMeasurement attributes:stringAttrs];
244 | CGSize fontWidth = [_unitOfMeasurement sizeWithAttributes:stringAttrs];
245 | [attrStr drawAtPoint:CGPointMake(0.5 - fontWidth.width / 2.0, 0.6)];
246 | }
247 |
248 | - (void)drawScale:(CGContextRef)context
249 | {
250 |
251 | CGContextSaveGState(context);
252 | [self rotateContext:context fromCenter:center withAngle:DEGREES_TO_RADIANS(180 + _scaleStartAngle)];
253 |
254 | int totalTicks = _scaleDivisions * _scaleSubdivisions + 1;
255 | for (int i = 0; i < totalTicks; i++)
256 | {
257 | CGFloat offset = 0.0;
258 | if (_scalesubdivisionsaligment == WMGaugeViewSubdivisionsAlignmentCenter) offset = (_scaleDivisionsLength - _scaleSubdivisionsLength) / 2.0;
259 | if (_scalesubdivisionsaligment == WMGaugeViewSubdivisionsAlignmentBottom) offset = _scaleDivisionsLength - _scaleSubdivisionsLength;
260 |
261 | CGFloat y1 = scaleRect.origin.y;
262 | CGFloat y2 = y1 + _scaleSubdivisionsLength;
263 | CGFloat y3 = y1 + _scaleDivisionsLength;
264 |
265 | float value = [self valueForTick:i];
266 | float div = (_maxValue - _minValue) / _scaleDivisions;
267 | float mod = (int)value % (int)div;
268 |
269 | if ((abs(mod - 0) < 0.000001) || (abs(mod - div) < 0.000001))
270 | {
271 | UIColor *color = (_rangeValues && _rangeColors)?[self rangeColorForValue:value]:_scaleDivisionColor;
272 | CGContextSetStrokeColorWithColor(context, color.CGColor);
273 | CGContextSetLineWidth(context, _scaleDivisionsWidth);
274 | CGContextSetShadow(context, CGSizeMake(0.05, 0.05), _showScaleShadow?2.0:0.0);
275 |
276 | CGContextMoveToPoint(context, 0.5, y1);
277 | CGContextAddLineToPoint(context, 0.5, y3);
278 | CGContextStrokePath(context);
279 |
280 | NSString *valueString = [NSString stringWithFormat:@"%0.0f",value];
281 | UIFont* font = _scaleFont?_scaleFont:[UIFont fontWithName:@"Helvetica-Bold" size:0.05];
282 | NSDictionary* stringAttrs = @{ NSFontAttributeName : font, NSForegroundColorAttributeName : color };
283 | NSAttributedString* attrStr = [[NSAttributedString alloc] initWithString:valueString attributes:stringAttrs];
284 | CGSize fontWidth = [valueString sizeWithAttributes:stringAttrs];
285 | [attrStr drawAtPoint:CGPointMake(0.5 - fontWidth.width / 2.0, y3 + 0.005)];
286 | }
287 | else
288 | {
289 | UIColor *color = (_rangeValues && _rangeColors)?[self rangeColorForValue:value]:_scaleSubDivisionColor;
290 | CGContextSetStrokeColorWithColor(context, color.CGColor);
291 | CGContextSetLineWidth(context, _scaleSubdivisionsWidth);
292 | CGContextMoveToPoint(context, 0.5, y1);
293 | if (_showScaleShadow) CGContextSetShadow(context, CGSizeMake(0.05, 0.05), 2.0);
294 |
295 | CGContextMoveToPoint(context, 0.5, y1 + offset);
296 | CGContextAddLineToPoint(context, 0.5, y2 + offset);
297 | CGContextStrokePath(context);
298 | }
299 |
300 | [self rotateContext:context fromCenter:center withAngle:DEGREES_TO_RADIANS(subdivisionAngle)];
301 | }
302 | CGContextRestoreGState(context);
303 |
304 | }
305 |
306 | - (void) drawStringAtContext:(CGContextRef) context string:(NSString*)text withCenter:(CGPoint)center_ radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle
307 | {
308 | CGContextSaveGState(context);
309 |
310 | UIFont* font = _scaleFont?_scaleFont:[UIFont fontWithName:@"Helvetica" size:0.05];
311 | NSDictionary* stringAttrs = @{ NSFontAttributeName : font, NSForegroundColorAttributeName : [UIColor whiteColor] };
312 | CGSize textSize = [text sizeWithAttributes:stringAttrs];
313 |
314 | float perimeter = 2 * M_PI * radius;
315 | float textAngle = textSize.width / perimeter * 2 * M_PI * _rangeLabelsFontKerning;
316 | float offset = ((endAngle - startAngle) - textAngle) / 2.0;
317 |
318 | float letterPosition = 0;
319 | NSString *lastLetter = @"";
320 |
321 | [self rotateContext:context fromCenter:center withAngle:startAngle + offset];
322 | for (int index = 0; index < [text length]; index++)
323 | {
324 | NSRange range = {index, 1};
325 | NSString* letter = [text substringWithRange:range];
326 | NSAttributedString* attrStr = [[NSAttributedString alloc] initWithString:letter attributes:stringAttrs];
327 | CGSize charSize = [letter sizeWithAttributes:stringAttrs];
328 |
329 | float totalWidth = [[NSString stringWithFormat:@"%@%@", lastLetter, letter] sizeWithAttributes:stringAttrs].width;
330 | float currentLetterWidth = [letter sizeWithAttributes:stringAttrs].width;
331 | float lastLetterWidth = [lastLetter sizeWithAttributes:stringAttrs].width;
332 | float kerning = (lastLetterWidth) ? 0 : ((currentLetterWidth + lastLetterWidth) - totalWidth);
333 |
334 | letterPosition += (charSize.width / 2) - kerning;
335 | float angle = (letterPosition / perimeter * 2 * M_PI) * _rangeLabelsFontKerning;
336 | CGPoint letterPoint = CGPointMake((radius - charSize.height / 2.0) * cos(angle) + center_.x, (radius - charSize.height / 2.0) * sin(angle) + center_.y);
337 |
338 | CGContextSaveGState(context);
339 | CGContextTranslateCTM(context, letterPoint.x, letterPoint.y);
340 | CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(angle + M_PI_2);
341 | CGContextConcatCTM(context, rotationTransform);
342 | CGContextTranslateCTM(context, -letterPoint.x, -letterPoint.y);
343 |
344 | [attrStr drawAtPoint:CGPointMake(letterPoint.x - charSize.width/2 , letterPoint.y - charSize.height)];
345 |
346 | CGContextRestoreGState(context);
347 |
348 | letterPosition += charSize.width / 2;
349 | lastLetter = letter;
350 | }
351 | CGContextRestoreGState(context);
352 | }
353 |
354 | - (void)drawRangeLabels:(CGContextRef)context
355 | {
356 | CGContextSaveGState(context);
357 | [self rotateContext:context fromCenter:center withAngle:DEGREES_TO_RADIANS(90 + _scaleStartAngle)];
358 | CGContextSetShadow(context, CGSizeMake(0.0, 0.0), 0.0);
359 |
360 | CGFloat maxAngle = _scaleEndAngle - _scaleStartAngle;
361 | CGFloat lastStartAngle = 0.0f;
362 |
363 | for (int i = 0; i < _rangeValues.count; i ++)
364 | {
365 | float value = ((NSNumber*)[_rangeValues objectAtIndex:i]).floatValue;
366 | float valueAngle = (value - _minValue) / (_maxValue - _minValue) * maxAngle;
367 |
368 | UIBezierPath *path = [UIBezierPath bezierPath];
369 | [path addArcWithCenter:center radius:rangeLabelsRect.size.width / 2.0 + 0.01 startAngle:DEGREES_TO_RADIANS(lastStartAngle) endAngle:DEGREES_TO_RADIANS(valueAngle) clockwise:YES];
370 |
371 | UIColor *color = _rangeColors[i];
372 | [color setStroke];
373 | path.lineWidth = _rangeLabelsWidth;
374 | [path stroke];
375 |
376 | [self drawStringAtContext:context string:(NSString*)_rangeLabels[i] withCenter:center radius:rangeLabelsRect.size.width / 2.0 + 0.008 startAngle:DEGREES_TO_RADIANS(lastStartAngle) endAngle:DEGREES_TO_RADIANS(valueAngle)];
377 |
378 | lastStartAngle = valueAngle;
379 | }
380 |
381 | CGContextRestoreGState(context);
382 | }
383 |
384 | - (void)drawNeedle:(CGContextRef)context
385 | {
386 | [self rotateContext:context fromCenter:center withAngle:DEGREES_TO_RADIANS(180 + _scaleStartAngle + (currentValue - _minValue) / (_maxValue - _minValue) * (_scaleEndAngle - _scaleStartAngle))];
387 |
388 | switch (_needleStyle)
389 | {
390 | case WMGaugeViewNeedleStyle3D:
391 | {
392 | CGContextSetShadow(context, CGSizeMake(0.05, 0.05), 8.0);
393 |
394 | // Left Needle
395 | UIBezierPath *leftNeedlePath = [UIBezierPath bezierPath];
396 | [leftNeedlePath moveToPoint:center];
397 | [leftNeedlePath addLineToPoint:CGPointMake(center.x - _needleWidth, center.y)];
398 | [leftNeedlePath addLineToPoint:CGPointMake(center.x, center.x - _needleHeight)];
399 | [leftNeedlePath closePath];
400 | [RGB(176, 10, 19) setFill];
401 | [leftNeedlePath fill];
402 |
403 | // Right Needle
404 | UIBezierPath *rightNeedlePath = [UIBezierPath bezierPath];
405 | [rightNeedlePath moveToPoint:center];
406 | [rightNeedlePath addLineToPoint:CGPointMake(center.x + _needleWidth, center.y)];
407 | [rightNeedlePath addLineToPoint:CGPointMake(center.x, center.x - _needleHeight)];
408 | [rightNeedlePath closePath];
409 | [RGB(252, 18, 30) setFill];
410 | [rightNeedlePath fill];
411 | }
412 | break;
413 |
414 | case WMGaugeViewNeedleStyleFlatThin:
415 | {
416 | UIBezierPath *needlePath = [UIBezierPath bezierPath];
417 | [needlePath moveToPoint:CGPointMake(center.x - _needleWidth, center.y)];
418 | [needlePath addLineToPoint:CGPointMake(center.x + _needleWidth, center.y)];
419 | [needlePath addLineToPoint:CGPointMake(center.x, center.x - _needleHeight)];
420 | [needlePath closePath];
421 |
422 | #define SHADOW_OFFSET 0.008
423 | CGContextTranslateCTM(context, -SHADOW_OFFSET, -SHADOW_OFFSET);
424 | [RGBA(0, 0, 0, 40) setFill];
425 | [RGBA(0, 0, 0, 20) setStroke];
426 | [needlePath fill];
427 | needlePath.lineWidth = 0.004;
428 | [needlePath stroke];
429 | CGContextTranslateCTM(context, SHADOW_OFFSET, SHADOW_OFFSET);
430 |
431 | // [RGB(255, 104, 97) setFill];
432 | [[UIColor lightGrayColor] setFill];
433 | // [UIColor colorWithRed:255/255.0 green:104/255.0 blue:97/255.0 alpha:1]
434 | // [RGB(255, 104, 97) setStroke];
435 | [[UIColor lightGrayColor] setStroke];
436 | // [UIColor colorWithRed:255/255.0 green:104/255.0 blue:97/255.0 alpha:1]
437 | [needlePath fill];
438 | needlePath.lineWidth = 0.004;
439 | [needlePath stroke];
440 | }
441 | break;
442 |
443 | default:
444 | break;
445 | }
446 |
447 | [self drawNeedleScrew:context];
448 | }
449 |
450 | - (void)drawNeedleScrew:(CGContextRef)context
451 | {
452 | switch (_needleScrewStyle)
453 | {
454 | case WMGaugeViewNeedleScrewStyleGradient:
455 | {
456 | // Screw
457 | CGColorSpaceRef baseSpace = CGColorSpaceCreateDeviceRGB();
458 | CGGradientRef gradient = CGGradientCreateWithColors(baseSpace, (CFArrayRef)@[iCGRGB(171, 171, 171), iCGRGB(255, 255, 255), iCGRGB(171, 171, 171)], (const CGFloat[]){0.05, 0.9, 1.00});
459 | CGColorSpaceRelease(baseSpace), baseSpace = NULL;
460 | CGContextAddEllipseInRect(context, CGRectMake(center.x - _needleScrewRadius, center.y - _needleScrewRadius, _needleScrewRadius * 2.0, _needleScrewRadius * 2.0));
461 | CGContextClip(context);
462 | CGContextDrawRadialGradient(context, gradient, center, 0, center, _needleScrewRadius * 2.0, kCGGradientDrawsAfterEndLocation);
463 | CGGradientRelease(gradient), gradient = NULL;
464 |
465 | // Border
466 | CGContextSetLineWidth(context, 0.005);
467 | CGContextSetStrokeColorWithColor(context, CGRGBA(81, 84, 89, 100));
468 | CGContextAddEllipseInRect(context, CGRectMake(center.x - _needleScrewRadius, center.y - _needleScrewRadius, _needleScrewRadius * 2.0, _needleScrewRadius * 2.0));
469 | CGContextStrokePath(context);
470 | }
471 | break;
472 |
473 | case WMGaugeViewNeedleScrewStylePlain:
474 | {
475 | CGContextAddEllipseInRect(context, CGRectMake(center.x - _needleScrewRadius, center.y - _needleScrewRadius, _needleScrewRadius * 2.0, _needleScrewRadius * 2.0));
476 | CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);
477 | // [UIColor colorWithRed:68/255.0 green:84/255.0 blue:105/255.0 alpha:1];
478 | CGContextFillPath(context);
479 | }
480 | break;
481 |
482 | default:
483 | break;
484 | }
485 | }
486 |
487 | - (void)initScale
488 | {
489 | scaleRotation = (int)(_scaleStartAngle + 180) % 360;
490 | divisionValue = (_maxValue - _minValue) / _scaleDivisions;
491 | subdivisionValue = divisionValue / _scaleSubdivisions;
492 | subdivisionAngle = (_scaleEndAngle - _scaleStartAngle) / (_scaleDivisions * _scaleSubdivisions);
493 | }
494 |
495 | - (float)valueForTick:(int)tick
496 | {
497 | return tick * (divisionValue / _scaleSubdivisions) + _minValue;
498 | }
499 |
500 | - (void)computeCurrentValue
501 | {
502 | if (currentValue == _value)
503 | return;
504 |
505 | if (-1 != needleLastMoved)
506 | {
507 | NSTimeInterval time = ([[NSDate date] timeIntervalSince1970] - needleLastMoved);
508 |
509 | needleAcceleration = 5.0 * (_value - currentValue);
510 | currentValue += needleVelocity * time;
511 | needleVelocity += needleAcceleration * time * 2.0;
512 |
513 | if (fabs(_value - currentValue) < (_maxValue - _minValue) * 0.01)
514 | {
515 | currentValue = _value;
516 | needleVelocity = 0.0;
517 | needleAcceleration = 0.0;
518 | needleLastMoved = -1;
519 | }
520 | else
521 | {
522 | needleLastMoved = [[NSDate date] timeIntervalSince1970];
523 | }
524 |
525 | dispatch_async(dispatch_get_main_queue(), ^(void)
526 | {
527 | [self setNeedsDisplay];
528 | });
529 | }
530 | else
531 | {
532 | needleLastMoved = [[NSDate date] timeIntervalSince1970];
533 | [self computeCurrentValue];
534 | }
535 | }
536 |
537 | - (UIColor*)rangeColorForValue:(float)value
538 | {
539 | NSInteger length = _rangeValues.count;
540 | for (int i = 0; i < length - 1; i++)
541 | {
542 | if (value < [_rangeValues[i] floatValue])
543 | return _rangeColors[i];
544 | }
545 | if (value <= [_rangeValues[length - 1] floatValue])
546 | return _rangeColors[length - 1];
547 | return nil;
548 | }
549 |
550 | - (void)invalidateBackground
551 | {
552 | background = nil;
553 | [self initDrawingRects];
554 | [self initScale];
555 | [self setNeedsDisplay];
556 | }
557 |
558 | #pragma mark - Properties
559 |
560 | - (void)setValue:(float)value
561 | {
562 | if (value > _maxValue)
563 | _value = _maxValue;
564 | else if (value < _minValue)
565 | _value = _minValue;
566 | else
567 | _value = value;
568 |
569 | needleVelocity = 0.0;
570 | needleAcceleration = 0.0;
571 | needleLastMoved = -1;
572 |
573 | [self setNeedsDisplay];
574 | }
575 |
576 | - (void)setValue:(float)value animated:(BOOL)animated
577 | {
578 | self.value = value;
579 | if (!animated)
580 | currentValue = _value;
581 | }
582 |
583 | - (void)setShowInnerBackground:(bool)showInnerBackground
584 | {
585 | _showInnerBackground = showInnerBackground;
586 | [self invalidateBackground];
587 | }
588 |
589 | - (void)setShowInnerRim:(bool)showInnerRim
590 | {
591 | _showInnerRim = showInnerRim;
592 | [self invalidateBackground];
593 | }
594 |
595 | - (void)setInnerRimWidth:(CGFloat)innerRimWidth
596 | {
597 | _innerRimWidth = innerRimWidth;
598 | [self invalidateBackground];
599 | }
600 |
601 | - (void)setInnerRimBordeWidth:(CGFloat)innerRimBorderWidth
602 | {
603 | _innerRimBorderWidth = innerRimBorderWidth;
604 | [self invalidateBackground];
605 | }
606 |
607 | - (void)setInnerBackgroundStyle:(WMGaugeViewInnerBackgroundStyle)innerBackgroundStyle
608 | {
609 | _innerBackgroundStyle = innerBackgroundStyle;
610 | [self invalidateBackground];
611 | }
612 |
613 | - (void)setNeedleWidth:(CGFloat)needleWidth
614 | {
615 | _needleWidth = needleWidth;
616 | [self setNeedsDisplay];
617 | }
618 |
619 | - (void)setNeedleHeight:(CGFloat)needleHeight
620 | {
621 | _needleHeight = needleHeight;
622 | [self setNeedsDisplay];
623 | }
624 |
625 | - (void)setNeedleScrewRadius:(CGFloat)needleScrewRadius
626 | {
627 | _needleScrewRadius = needleScrewRadius;
628 | [self setNeedsDisplay];
629 | }
630 |
631 | - (void)setNeedleStyle:(WMGaugeViewNeedleStyle)needleStyle
632 | {
633 | _needleStyle = needleStyle;
634 | [self setNeedsDisplay];
635 | }
636 |
637 | - (void)setNeedleScrewStyle:(WMGaugeViewNeedleScrewStyle)needleScrewStyle
638 | {
639 | _needleScrewStyle = needleScrewStyle;
640 | [self setNeedsDisplay];
641 | }
642 |
643 | - (void)setScalePosition:(CGFloat)scalePosition
644 | {
645 | _scalePosition = scalePosition;
646 | [self invalidateBackground];
647 | }
648 |
649 | - (void)setScaleStartAngle:(CGFloat)scaleStartAngle
650 | {
651 | _scaleStartAngle = scaleStartAngle;
652 | [self invalidateBackground];
653 | }
654 |
655 | - (void)setScaleEndAngle:(CGFloat)scaleEndAngle
656 | {
657 | _scaleEndAngle = scaleEndAngle;
658 | [self invalidateBackground];
659 | }
660 |
661 | - (void)setScaleDivisions:(CGFloat)scaleDivisions
662 | {
663 | _scaleDivisions = scaleDivisions;
664 | [self invalidateBackground];
665 | }
666 |
667 | - (void)setScaleSubdivisions:(CGFloat)scaleSubdivisions
668 | {
669 | _scaleSubdivisions = scaleSubdivisions;
670 | [self invalidateBackground];
671 | }
672 |
673 | - (void)setShowScaleShadow:(bool)showScaleShadow
674 | {
675 | _showScaleShadow = showScaleShadow;
676 | [self invalidateBackground];
677 | }
678 |
679 | - (void)setScalesubdivisionsaligment:(WMGaugeViewSubdivisionsAlignment)scalesubdivisionsaligment
680 | {
681 | _scalesubdivisionsaligment = scalesubdivisionsaligment;
682 | [self invalidateBackground];
683 | }
684 |
685 | - (void)setScaleDivisionsLength:(CGFloat)scaleDivisionsLength
686 | {
687 | _scaleDivisionsLength = scaleDivisionsLength;
688 | [self invalidateBackground];
689 | }
690 |
691 | - (void)setScaleDivisionsWidth:(CGFloat)scaleDivisionsWidth
692 | {
693 | _scaleDivisionsWidth = scaleDivisionsWidth;
694 | [self invalidateBackground];
695 | }
696 |
697 | - (void)setScaleSubdivisionsLength:(CGFloat)scaleSubdivisionsLength
698 | {
699 | _scaleSubdivisionsLength = scaleSubdivisionsLength;
700 | [self invalidateBackground];
701 | }
702 |
703 | - (void)setScaleSubdivisionsWidth:(CGFloat)scaleSubdivisionsWidth
704 | {
705 | _scaleSubdivisionsWidth = scaleSubdivisionsWidth;
706 | [self invalidateBackground];
707 | }
708 |
709 | - (void)setScaleDivisionColor:(UIColor *)scaleDivisionColor
710 | {
711 | _scaleDivisionColor = scaleDivisionColor;
712 | [self invalidateBackground];
713 | }
714 |
715 | - (void)setScaleSubDivisionColor:(UIColor *)scaleSubDivisionColor
716 | {
717 | _scaleSubDivisionColor = scaleSubDivisionColor;
718 | [self invalidateBackground];
719 | }
720 |
721 | - (void)setScaleFont:(UIFont *)scaleFont
722 | {
723 | _scaleFont = scaleFont;
724 | [self invalidateBackground];
725 | }
726 |
727 | - (void)setRangeLabelsWidth:(CGFloat)rangeLabelsWidth
728 | {
729 | _rangeLabelsWidth = rangeLabelsWidth;
730 | [self invalidateBackground];
731 | }
732 |
733 | - (void)setMinValue:(float)minValue
734 | {
735 | _minValue = minValue;
736 | [self invalidateBackground];
737 | }
738 |
739 | - (void)setMaxValue:(float)maxValue
740 | {
741 | _maxValue = maxValue;
742 | [self invalidateBackground];
743 | }
744 |
745 | - (void)setRangeValues:(NSArray *)rangeValues
746 | {
747 | _rangeValues = rangeValues;
748 | [self invalidateBackground];
749 | }
750 |
751 | - (void)setRangeColors:(NSArray *)rangeColors
752 | {
753 | _rangeColors = rangeColors;
754 | [self invalidateBackground];
755 | }
756 |
757 | - (void)setRangeLabels:(NSArray *)rangeLabels
758 | {
759 | _rangeLabels = rangeLabels;
760 | [self invalidateBackground];
761 | }
762 |
763 | - (void)setUnitOfMeasurement:(NSString *)unitOfMeasurement
764 | {
765 | _unitOfMeasurement = unitOfMeasurement;
766 | [self invalidateBackground];
767 | }
768 |
769 | - (void)setShowUnitOfMeasurement:(bool)showUnitOfMeasurement
770 | {
771 | _showUnitOfMeasurement = showUnitOfMeasurement;
772 | [self invalidateBackground];
773 | }
774 |
775 | - (void)setShowRangeLabels:(bool)showRangeLabels
776 | {
777 | _showRangeLabels = showRangeLabels;
778 | [self invalidateBackground];
779 | }
780 |
781 | - (void)setRangeLabelsFontKerning:(CGFloat)rangeLabelsFontKerning
782 | {
783 | _rangeLabelsFontKerning = rangeLabelsFontKerning;
784 | [self invalidateBackground];
785 | }
786 |
787 | @end
788 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitor/ZYDMonitor.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.application-groups
6 |
7 | group.ZYDMonitor
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 16CD88EF1C5657140057213E /* UIView+Category.m in Sources */ = {isa = PBXBuildFile; fileRef = 16CD88EE1C5657140057213E /* UIView+Category.m */; };
11 | 16E7BA9E1BFA651700148E3D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 16E7BA9D1BFA651700148E3D /* main.m */; };
12 | 16E7BAA11BFA651700148E3D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 16E7BAA01BFA651700148E3D /* AppDelegate.m */; };
13 | 16E7BAA41BFA651700148E3D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 16E7BAA31BFA651700148E3D /* ViewController.m */; };
14 | 16E7BAA71BFA651700148E3D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 16E7BAA51BFA651700148E3D /* Main.storyboard */; };
15 | 16E7BAA91BFA651700148E3D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 16E7BAA81BFA651700148E3D /* Assets.xcassets */; };
16 | 16E7BAAC1BFA651700148E3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 16E7BAAA1BFA651700148E3D /* LaunchScreen.storyboard */; };
17 | 16E7BAB71BFA651700148E3D /* ZYDMonitorDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 16E7BAB61BFA651700148E3D /* ZYDMonitorDemoTests.m */; };
18 | 16E7BAC21BFA651700148E3D /* ZYDMonitorDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 16E7BAC11BFA651700148E3D /* ZYDMonitorDemoUITests.m */; };
19 | 16E7BAD61BFA651700148E3D /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 16E7BAD51BFA651700148E3D /* NotificationCenter.framework */; };
20 | 16E7BADA1BFA651700148E3D /* TodayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 16E7BAD91BFA651700148E3D /* TodayViewController.m */; };
21 | 16E7BADD1BFA651700148E3D /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 16E7BADB1BFA651700148E3D /* MainInterface.storyboard */; };
22 | 16E7BAE11BFA651700148E3D /* ZYDMonitor.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 16E7BAD31BFA651700148E3D /* ZYDMonitor.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
23 | 16E7BAEA1BFB436D00148E3D /* WMGaugeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 16E7BAE91BFB436D00148E3D /* WMGaugeView.m */; };
24 | 16E7BAED1BFB466C00148E3D /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 16E7BAEC1BFB466C00148E3D /* Reachability.m */; };
25 | /* End PBXBuildFile section */
26 |
27 | /* Begin PBXContainerItemProxy section */
28 | 16E7BAB31BFA651700148E3D /* PBXContainerItemProxy */ = {
29 | isa = PBXContainerItemProxy;
30 | containerPortal = 16E7BA911BFA651700148E3D /* Project object */;
31 | proxyType = 1;
32 | remoteGlobalIDString = 16E7BA981BFA651700148E3D;
33 | remoteInfo = ZYDMonitorDemo;
34 | };
35 | 16E7BABE1BFA651700148E3D /* PBXContainerItemProxy */ = {
36 | isa = PBXContainerItemProxy;
37 | containerPortal = 16E7BA911BFA651700148E3D /* Project object */;
38 | proxyType = 1;
39 | remoteGlobalIDString = 16E7BA981BFA651700148E3D;
40 | remoteInfo = ZYDMonitorDemo;
41 | };
42 | 16E7BADF1BFA651700148E3D /* PBXContainerItemProxy */ = {
43 | isa = PBXContainerItemProxy;
44 | containerPortal = 16E7BA911BFA651700148E3D /* Project object */;
45 | proxyType = 1;
46 | remoteGlobalIDString = 16E7BAD21BFA651700148E3D;
47 | remoteInfo = ZYDMonitor;
48 | };
49 | /* End PBXContainerItemProxy section */
50 |
51 | /* Begin PBXCopyFilesBuildPhase section */
52 | 16E7BAE51BFA651700148E3D /* Embed App Extensions */ = {
53 | isa = PBXCopyFilesBuildPhase;
54 | buildActionMask = 2147483647;
55 | dstPath = "";
56 | dstSubfolderSpec = 13;
57 | files = (
58 | 16E7BAE11BFA651700148E3D /* ZYDMonitor.appex in Embed App Extensions */,
59 | );
60 | name = "Embed App Extensions";
61 | runOnlyForDeploymentPostprocessing = 0;
62 | };
63 | /* End PBXCopyFilesBuildPhase section */
64 |
65 | /* Begin PBXFileReference section */
66 | 16CD88ED1C5657140057213E /* UIView+Category.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Category.h"; sourceTree = ""; };
67 | 16CD88EE1C5657140057213E /* UIView+Category.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Category.m"; sourceTree = ""; };
68 | 16E7BA991BFA651700148E3D /* ZYDMonitorDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZYDMonitorDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
69 | 16E7BA9D1BFA651700148E3D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
70 | 16E7BA9F1BFA651700148E3D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
71 | 16E7BAA01BFA651700148E3D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
72 | 16E7BAA21BFA651700148E3D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
73 | 16E7BAA31BFA651700148E3D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
74 | 16E7BAA61BFA651700148E3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
75 | 16E7BAA81BFA651700148E3D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
76 | 16E7BAAB1BFA651700148E3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
77 | 16E7BAAD1BFA651700148E3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
78 | 16E7BAB21BFA651700148E3D /* ZYDMonitorDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ZYDMonitorDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
79 | 16E7BAB61BFA651700148E3D /* ZYDMonitorDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZYDMonitorDemoTests.m; sourceTree = ""; };
80 | 16E7BAB81BFA651700148E3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
81 | 16E7BABD1BFA651700148E3D /* ZYDMonitorDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ZYDMonitorDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
82 | 16E7BAC11BFA651700148E3D /* ZYDMonitorDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZYDMonitorDemoUITests.m; sourceTree = ""; };
83 | 16E7BAC31BFA651700148E3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
84 | 16E7BAD31BFA651700148E3D /* ZYDMonitor.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ZYDMonitor.appex; sourceTree = BUILT_PRODUCTS_DIR; };
85 | 16E7BAD51BFA651700148E3D /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; };
86 | 16E7BAD81BFA651700148E3D /* TodayViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TodayViewController.h; sourceTree = ""; };
87 | 16E7BAD91BFA651700148E3D /* TodayViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TodayViewController.m; sourceTree = ""; };
88 | 16E7BADC1BFA651700148E3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; };
89 | 16E7BADE1BFA651700148E3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
90 | 16E7BAE61BFA651700148E3D /* ZYDMonitor.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = ZYDMonitor.entitlements; sourceTree = ""; };
91 | 16E7BAE71BFA651700148E3D /* ZYDMonitorDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = ZYDMonitorDemo.entitlements; sourceTree = ""; };
92 | 16E7BAE81BFB436D00148E3D /* WMGaugeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMGaugeView.h; sourceTree = ""; };
93 | 16E7BAE91BFB436D00148E3D /* WMGaugeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMGaugeView.m; sourceTree = ""; };
94 | 16E7BAEB1BFB466C00148E3D /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = ""; };
95 | 16E7BAEC1BFB466C00148E3D /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = ""; };
96 | /* End PBXFileReference section */
97 |
98 | /* Begin PBXFrameworksBuildPhase section */
99 | 16E7BA961BFA651700148E3D /* Frameworks */ = {
100 | isa = PBXFrameworksBuildPhase;
101 | buildActionMask = 2147483647;
102 | files = (
103 | );
104 | runOnlyForDeploymentPostprocessing = 0;
105 | };
106 | 16E7BAAF1BFA651700148E3D /* Frameworks */ = {
107 | isa = PBXFrameworksBuildPhase;
108 | buildActionMask = 2147483647;
109 | files = (
110 | );
111 | runOnlyForDeploymentPostprocessing = 0;
112 | };
113 | 16E7BABA1BFA651700148E3D /* Frameworks */ = {
114 | isa = PBXFrameworksBuildPhase;
115 | buildActionMask = 2147483647;
116 | files = (
117 | );
118 | runOnlyForDeploymentPostprocessing = 0;
119 | };
120 | 16E7BAD01BFA651700148E3D /* Frameworks */ = {
121 | isa = PBXFrameworksBuildPhase;
122 | buildActionMask = 2147483647;
123 | files = (
124 | 16E7BAD61BFA651700148E3D /* NotificationCenter.framework in Frameworks */,
125 | );
126 | runOnlyForDeploymentPostprocessing = 0;
127 | };
128 | /* End PBXFrameworksBuildPhase section */
129 |
130 | /* Begin PBXGroup section */
131 | 16E7BA901BFA651700148E3D = {
132 | isa = PBXGroup;
133 | children = (
134 | 16E7BA9B1BFA651700148E3D /* ZYDMonitorDemo */,
135 | 16E7BAB51BFA651700148E3D /* ZYDMonitorDemoTests */,
136 | 16E7BAC01BFA651700148E3D /* ZYDMonitorDemoUITests */,
137 | 16E7BAD71BFA651700148E3D /* ZYDMonitor */,
138 | 16E7BAD41BFA651700148E3D /* Frameworks */,
139 | 16E7BA9A1BFA651700148E3D /* Products */,
140 | );
141 | sourceTree = "";
142 | };
143 | 16E7BA9A1BFA651700148E3D /* Products */ = {
144 | isa = PBXGroup;
145 | children = (
146 | 16E7BA991BFA651700148E3D /* ZYDMonitorDemo.app */,
147 | 16E7BAB21BFA651700148E3D /* ZYDMonitorDemoTests.xctest */,
148 | 16E7BABD1BFA651700148E3D /* ZYDMonitorDemoUITests.xctest */,
149 | 16E7BAD31BFA651700148E3D /* ZYDMonitor.appex */,
150 | );
151 | name = Products;
152 | sourceTree = "";
153 | };
154 | 16E7BA9B1BFA651700148E3D /* ZYDMonitorDemo */ = {
155 | isa = PBXGroup;
156 | children = (
157 | 16CD88ED1C5657140057213E /* UIView+Category.h */,
158 | 16CD88EE1C5657140057213E /* UIView+Category.m */,
159 | 16E7BAE71BFA651700148E3D /* ZYDMonitorDemo.entitlements */,
160 | 16E7BA9F1BFA651700148E3D /* AppDelegate.h */,
161 | 16E7BAA01BFA651700148E3D /* AppDelegate.m */,
162 | 16E7BAA21BFA651700148E3D /* ViewController.h */,
163 | 16E7BAA31BFA651700148E3D /* ViewController.m */,
164 | 16E7BAA51BFA651700148E3D /* Main.storyboard */,
165 | 16E7BAA81BFA651700148E3D /* Assets.xcassets */,
166 | 16E7BAAA1BFA651700148E3D /* LaunchScreen.storyboard */,
167 | 16E7BAAD1BFA651700148E3D /* Info.plist */,
168 | 16E7BA9C1BFA651700148E3D /* Supporting Files */,
169 | );
170 | path = ZYDMonitorDemo;
171 | sourceTree = "";
172 | };
173 | 16E7BA9C1BFA651700148E3D /* Supporting Files */ = {
174 | isa = PBXGroup;
175 | children = (
176 | 16E7BA9D1BFA651700148E3D /* main.m */,
177 | );
178 | name = "Supporting Files";
179 | sourceTree = "";
180 | };
181 | 16E7BAB51BFA651700148E3D /* ZYDMonitorDemoTests */ = {
182 | isa = PBXGroup;
183 | children = (
184 | 16E7BAB61BFA651700148E3D /* ZYDMonitorDemoTests.m */,
185 | 16E7BAB81BFA651700148E3D /* Info.plist */,
186 | );
187 | path = ZYDMonitorDemoTests;
188 | sourceTree = "";
189 | };
190 | 16E7BAC01BFA651700148E3D /* ZYDMonitorDemoUITests */ = {
191 | isa = PBXGroup;
192 | children = (
193 | 16E7BAC11BFA651700148E3D /* ZYDMonitorDemoUITests.m */,
194 | 16E7BAC31BFA651700148E3D /* Info.plist */,
195 | );
196 | path = ZYDMonitorDemoUITests;
197 | sourceTree = "";
198 | };
199 | 16E7BAD41BFA651700148E3D /* Frameworks */ = {
200 | isa = PBXGroup;
201 | children = (
202 | 16E7BAD51BFA651700148E3D /* NotificationCenter.framework */,
203 | );
204 | name = Frameworks;
205 | sourceTree = "";
206 | };
207 | 16E7BAD71BFA651700148E3D /* ZYDMonitor */ = {
208 | isa = PBXGroup;
209 | children = (
210 | 16E7BAE61BFA651700148E3D /* ZYDMonitor.entitlements */,
211 | 16E7BAD81BFA651700148E3D /* TodayViewController.h */,
212 | 16E7BAD91BFA651700148E3D /* TodayViewController.m */,
213 | 16E7BADB1BFA651700148E3D /* MainInterface.storyboard */,
214 | 16E7BAE81BFB436D00148E3D /* WMGaugeView.h */,
215 | 16E7BAE91BFB436D00148E3D /* WMGaugeView.m */,
216 | 16E7BAEB1BFB466C00148E3D /* Reachability.h */,
217 | 16E7BAEC1BFB466C00148E3D /* Reachability.m */,
218 | 16E7BADE1BFA651700148E3D /* Info.plist */,
219 | );
220 | path = ZYDMonitor;
221 | sourceTree = "";
222 | };
223 | /* End PBXGroup section */
224 |
225 | /* Begin PBXNativeTarget section */
226 | 16E7BA981BFA651700148E3D /* ZYDMonitorDemo */ = {
227 | isa = PBXNativeTarget;
228 | buildConfigurationList = 16E7BAC61BFA651700148E3D /* Build configuration list for PBXNativeTarget "ZYDMonitorDemo" */;
229 | buildPhases = (
230 | 16E7BA951BFA651700148E3D /* Sources */,
231 | 16E7BA961BFA651700148E3D /* Frameworks */,
232 | 16E7BA971BFA651700148E3D /* Resources */,
233 | 16E7BAE51BFA651700148E3D /* Embed App Extensions */,
234 | );
235 | buildRules = (
236 | );
237 | dependencies = (
238 | 16E7BAE01BFA651700148E3D /* PBXTargetDependency */,
239 | );
240 | name = ZYDMonitorDemo;
241 | productName = ZYDMonitorDemo;
242 | productReference = 16E7BA991BFA651700148E3D /* ZYDMonitorDemo.app */;
243 | productType = "com.apple.product-type.application";
244 | };
245 | 16E7BAB11BFA651700148E3D /* ZYDMonitorDemoTests */ = {
246 | isa = PBXNativeTarget;
247 | buildConfigurationList = 16E7BAC91BFA651700148E3D /* Build configuration list for PBXNativeTarget "ZYDMonitorDemoTests" */;
248 | buildPhases = (
249 | 16E7BAAE1BFA651700148E3D /* Sources */,
250 | 16E7BAAF1BFA651700148E3D /* Frameworks */,
251 | 16E7BAB01BFA651700148E3D /* Resources */,
252 | );
253 | buildRules = (
254 | );
255 | dependencies = (
256 | 16E7BAB41BFA651700148E3D /* PBXTargetDependency */,
257 | );
258 | name = ZYDMonitorDemoTests;
259 | productName = ZYDMonitorDemoTests;
260 | productReference = 16E7BAB21BFA651700148E3D /* ZYDMonitorDemoTests.xctest */;
261 | productType = "com.apple.product-type.bundle.unit-test";
262 | };
263 | 16E7BABC1BFA651700148E3D /* ZYDMonitorDemoUITests */ = {
264 | isa = PBXNativeTarget;
265 | buildConfigurationList = 16E7BACC1BFA651700148E3D /* Build configuration list for PBXNativeTarget "ZYDMonitorDemoUITests" */;
266 | buildPhases = (
267 | 16E7BAB91BFA651700148E3D /* Sources */,
268 | 16E7BABA1BFA651700148E3D /* Frameworks */,
269 | 16E7BABB1BFA651700148E3D /* Resources */,
270 | );
271 | buildRules = (
272 | );
273 | dependencies = (
274 | 16E7BABF1BFA651700148E3D /* PBXTargetDependency */,
275 | );
276 | name = ZYDMonitorDemoUITests;
277 | productName = ZYDMonitorDemoUITests;
278 | productReference = 16E7BABD1BFA651700148E3D /* ZYDMonitorDemoUITests.xctest */;
279 | productType = "com.apple.product-type.bundle.ui-testing";
280 | };
281 | 16E7BAD21BFA651700148E3D /* ZYDMonitor */ = {
282 | isa = PBXNativeTarget;
283 | buildConfigurationList = 16E7BAE21BFA651700148E3D /* Build configuration list for PBXNativeTarget "ZYDMonitor" */;
284 | buildPhases = (
285 | 16E7BACF1BFA651700148E3D /* Sources */,
286 | 16E7BAD01BFA651700148E3D /* Frameworks */,
287 | 16E7BAD11BFA651700148E3D /* Resources */,
288 | );
289 | buildRules = (
290 | );
291 | dependencies = (
292 | );
293 | name = ZYDMonitor;
294 | productName = ZYDMonitor;
295 | productReference = 16E7BAD31BFA651700148E3D /* ZYDMonitor.appex */;
296 | productType = "com.apple.product-type.app-extension";
297 | };
298 | /* End PBXNativeTarget section */
299 |
300 | /* Begin PBXProject section */
301 | 16E7BA911BFA651700148E3D /* Project object */ = {
302 | isa = PBXProject;
303 | attributes = {
304 | LastUpgradeCheck = 0710;
305 | ORGANIZATIONNAME = zyd;
306 | TargetAttributes = {
307 | 16E7BA981BFA651700148E3D = {
308 | CreatedOnToolsVersion = 7.1;
309 | DevelopmentTeam = GZ9LDY5863;
310 | SystemCapabilities = {
311 | com.apple.ApplicationGroups.iOS = {
312 | enabled = 1;
313 | };
314 | };
315 | };
316 | 16E7BAB11BFA651700148E3D = {
317 | CreatedOnToolsVersion = 7.1;
318 | TestTargetID = 16E7BA981BFA651700148E3D;
319 | };
320 | 16E7BABC1BFA651700148E3D = {
321 | CreatedOnToolsVersion = 7.1;
322 | TestTargetID = 16E7BA981BFA651700148E3D;
323 | };
324 | 16E7BAD21BFA651700148E3D = {
325 | CreatedOnToolsVersion = 7.1;
326 | DevelopmentTeam = GZ9LDY5863;
327 | SystemCapabilities = {
328 | com.apple.ApplicationGroups.iOS = {
329 | enabled = 1;
330 | };
331 | };
332 | };
333 | };
334 | };
335 | buildConfigurationList = 16E7BA941BFA651700148E3D /* Build configuration list for PBXProject "ZYDMonitorDemo" */;
336 | compatibilityVersion = "Xcode 3.2";
337 | developmentRegion = English;
338 | hasScannedForEncodings = 0;
339 | knownRegions = (
340 | en,
341 | Base,
342 | );
343 | mainGroup = 16E7BA901BFA651700148E3D;
344 | productRefGroup = 16E7BA9A1BFA651700148E3D /* Products */;
345 | projectDirPath = "";
346 | projectRoot = "";
347 | targets = (
348 | 16E7BA981BFA651700148E3D /* ZYDMonitorDemo */,
349 | 16E7BAB11BFA651700148E3D /* ZYDMonitorDemoTests */,
350 | 16E7BABC1BFA651700148E3D /* ZYDMonitorDemoUITests */,
351 | 16E7BAD21BFA651700148E3D /* ZYDMonitor */,
352 | );
353 | };
354 | /* End PBXProject section */
355 |
356 | /* Begin PBXResourcesBuildPhase section */
357 | 16E7BA971BFA651700148E3D /* Resources */ = {
358 | isa = PBXResourcesBuildPhase;
359 | buildActionMask = 2147483647;
360 | files = (
361 | 16E7BAAC1BFA651700148E3D /* LaunchScreen.storyboard in Resources */,
362 | 16E7BAA91BFA651700148E3D /* Assets.xcassets in Resources */,
363 | 16E7BAA71BFA651700148E3D /* Main.storyboard in Resources */,
364 | );
365 | runOnlyForDeploymentPostprocessing = 0;
366 | };
367 | 16E7BAB01BFA651700148E3D /* Resources */ = {
368 | isa = PBXResourcesBuildPhase;
369 | buildActionMask = 2147483647;
370 | files = (
371 | );
372 | runOnlyForDeploymentPostprocessing = 0;
373 | };
374 | 16E7BABB1BFA651700148E3D /* Resources */ = {
375 | isa = PBXResourcesBuildPhase;
376 | buildActionMask = 2147483647;
377 | files = (
378 | );
379 | runOnlyForDeploymentPostprocessing = 0;
380 | };
381 | 16E7BAD11BFA651700148E3D /* Resources */ = {
382 | isa = PBXResourcesBuildPhase;
383 | buildActionMask = 2147483647;
384 | files = (
385 | 16E7BADD1BFA651700148E3D /* MainInterface.storyboard in Resources */,
386 | );
387 | runOnlyForDeploymentPostprocessing = 0;
388 | };
389 | /* End PBXResourcesBuildPhase section */
390 |
391 | /* Begin PBXSourcesBuildPhase section */
392 | 16E7BA951BFA651700148E3D /* Sources */ = {
393 | isa = PBXSourcesBuildPhase;
394 | buildActionMask = 2147483647;
395 | files = (
396 | 16E7BAA41BFA651700148E3D /* ViewController.m in Sources */,
397 | 16E7BAA11BFA651700148E3D /* AppDelegate.m in Sources */,
398 | 16CD88EF1C5657140057213E /* UIView+Category.m in Sources */,
399 | 16E7BA9E1BFA651700148E3D /* main.m in Sources */,
400 | );
401 | runOnlyForDeploymentPostprocessing = 0;
402 | };
403 | 16E7BAAE1BFA651700148E3D /* Sources */ = {
404 | isa = PBXSourcesBuildPhase;
405 | buildActionMask = 2147483647;
406 | files = (
407 | 16E7BAB71BFA651700148E3D /* ZYDMonitorDemoTests.m in Sources */,
408 | );
409 | runOnlyForDeploymentPostprocessing = 0;
410 | };
411 | 16E7BAB91BFA651700148E3D /* Sources */ = {
412 | isa = PBXSourcesBuildPhase;
413 | buildActionMask = 2147483647;
414 | files = (
415 | 16E7BAC21BFA651700148E3D /* ZYDMonitorDemoUITests.m in Sources */,
416 | );
417 | runOnlyForDeploymentPostprocessing = 0;
418 | };
419 | 16E7BACF1BFA651700148E3D /* Sources */ = {
420 | isa = PBXSourcesBuildPhase;
421 | buildActionMask = 2147483647;
422 | files = (
423 | 16E7BAEA1BFB436D00148E3D /* WMGaugeView.m in Sources */,
424 | 16E7BAED1BFB466C00148E3D /* Reachability.m in Sources */,
425 | 16E7BADA1BFA651700148E3D /* TodayViewController.m in Sources */,
426 | );
427 | runOnlyForDeploymentPostprocessing = 0;
428 | };
429 | /* End PBXSourcesBuildPhase section */
430 |
431 | /* Begin PBXTargetDependency section */
432 | 16E7BAB41BFA651700148E3D /* PBXTargetDependency */ = {
433 | isa = PBXTargetDependency;
434 | target = 16E7BA981BFA651700148E3D /* ZYDMonitorDemo */;
435 | targetProxy = 16E7BAB31BFA651700148E3D /* PBXContainerItemProxy */;
436 | };
437 | 16E7BABF1BFA651700148E3D /* PBXTargetDependency */ = {
438 | isa = PBXTargetDependency;
439 | target = 16E7BA981BFA651700148E3D /* ZYDMonitorDemo */;
440 | targetProxy = 16E7BABE1BFA651700148E3D /* PBXContainerItemProxy */;
441 | };
442 | 16E7BAE01BFA651700148E3D /* PBXTargetDependency */ = {
443 | isa = PBXTargetDependency;
444 | target = 16E7BAD21BFA651700148E3D /* ZYDMonitor */;
445 | targetProxy = 16E7BADF1BFA651700148E3D /* PBXContainerItemProxy */;
446 | };
447 | /* End PBXTargetDependency section */
448 |
449 | /* Begin PBXVariantGroup section */
450 | 16E7BAA51BFA651700148E3D /* Main.storyboard */ = {
451 | isa = PBXVariantGroup;
452 | children = (
453 | 16E7BAA61BFA651700148E3D /* Base */,
454 | );
455 | name = Main.storyboard;
456 | sourceTree = "";
457 | };
458 | 16E7BAAA1BFA651700148E3D /* LaunchScreen.storyboard */ = {
459 | isa = PBXVariantGroup;
460 | children = (
461 | 16E7BAAB1BFA651700148E3D /* Base */,
462 | );
463 | name = LaunchScreen.storyboard;
464 | sourceTree = "";
465 | };
466 | 16E7BADB1BFA651700148E3D /* MainInterface.storyboard */ = {
467 | isa = PBXVariantGroup;
468 | children = (
469 | 16E7BADC1BFA651700148E3D /* Base */,
470 | );
471 | name = MainInterface.storyboard;
472 | sourceTree = "";
473 | };
474 | /* End PBXVariantGroup section */
475 |
476 | /* Begin XCBuildConfiguration section */
477 | 16E7BAC41BFA651700148E3D /* Debug */ = {
478 | isa = XCBuildConfiguration;
479 | buildSettings = {
480 | ALWAYS_SEARCH_USER_PATHS = NO;
481 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
482 | CLANG_CXX_LIBRARY = "libc++";
483 | CLANG_ENABLE_MODULES = YES;
484 | CLANG_ENABLE_OBJC_ARC = YES;
485 | CLANG_WARN_BOOL_CONVERSION = YES;
486 | CLANG_WARN_CONSTANT_CONVERSION = YES;
487 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
488 | CLANG_WARN_EMPTY_BODY = YES;
489 | CLANG_WARN_ENUM_CONVERSION = YES;
490 | CLANG_WARN_INT_CONVERSION = YES;
491 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
492 | CLANG_WARN_UNREACHABLE_CODE = YES;
493 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
494 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
495 | COPY_PHASE_STRIP = NO;
496 | DEBUG_INFORMATION_FORMAT = dwarf;
497 | ENABLE_STRICT_OBJC_MSGSEND = YES;
498 | ENABLE_TESTABILITY = YES;
499 | GCC_C_LANGUAGE_STANDARD = gnu99;
500 | GCC_DYNAMIC_NO_PIC = NO;
501 | GCC_NO_COMMON_BLOCKS = YES;
502 | GCC_OPTIMIZATION_LEVEL = 0;
503 | GCC_PREPROCESSOR_DEFINITIONS = (
504 | "DEBUG=1",
505 | "$(inherited)",
506 | );
507 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
508 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
509 | GCC_WARN_UNDECLARED_SELECTOR = YES;
510 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
511 | GCC_WARN_UNUSED_FUNCTION = YES;
512 | GCC_WARN_UNUSED_VARIABLE = YES;
513 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
514 | MTL_ENABLE_DEBUG_INFO = YES;
515 | ONLY_ACTIVE_ARCH = YES;
516 | SDKROOT = iphoneos;
517 | };
518 | name = Debug;
519 | };
520 | 16E7BAC51BFA651700148E3D /* Release */ = {
521 | isa = XCBuildConfiguration;
522 | buildSettings = {
523 | ALWAYS_SEARCH_USER_PATHS = NO;
524 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
525 | CLANG_CXX_LIBRARY = "libc++";
526 | CLANG_ENABLE_MODULES = YES;
527 | CLANG_ENABLE_OBJC_ARC = YES;
528 | CLANG_WARN_BOOL_CONVERSION = YES;
529 | CLANG_WARN_CONSTANT_CONVERSION = YES;
530 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
531 | CLANG_WARN_EMPTY_BODY = YES;
532 | CLANG_WARN_ENUM_CONVERSION = YES;
533 | CLANG_WARN_INT_CONVERSION = YES;
534 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
535 | CLANG_WARN_UNREACHABLE_CODE = YES;
536 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
537 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
538 | COPY_PHASE_STRIP = NO;
539 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
540 | ENABLE_NS_ASSERTIONS = NO;
541 | ENABLE_STRICT_OBJC_MSGSEND = YES;
542 | GCC_C_LANGUAGE_STANDARD = gnu99;
543 | GCC_NO_COMMON_BLOCKS = YES;
544 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
545 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
546 | GCC_WARN_UNDECLARED_SELECTOR = YES;
547 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
548 | GCC_WARN_UNUSED_FUNCTION = YES;
549 | GCC_WARN_UNUSED_VARIABLE = YES;
550 | IPHONEOS_DEPLOYMENT_TARGET = 9.1;
551 | MTL_ENABLE_DEBUG_INFO = NO;
552 | SDKROOT = iphoneos;
553 | VALIDATE_PRODUCT = YES;
554 | };
555 | name = Release;
556 | };
557 | 16E7BAC71BFA651700148E3D /* Debug */ = {
558 | isa = XCBuildConfiguration;
559 | buildSettings = {
560 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
561 | CODE_SIGN_ENTITLEMENTS = ZYDMonitorDemo/ZYDMonitorDemo.entitlements;
562 | CODE_SIGN_IDENTITY = "iPhone Developer";
563 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
564 | INFOPLIST_FILE = ZYDMonitorDemo/Info.plist;
565 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
566 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
567 | PRODUCT_BUNDLE_IDENTIFIER = com.zyd.ZYDMonitorDemo1;
568 | PRODUCT_NAME = "$(TARGET_NAME)";
569 | PROVISIONING_PROFILE = "";
570 | };
571 | name = Debug;
572 | };
573 | 16E7BAC81BFA651700148E3D /* Release */ = {
574 | isa = XCBuildConfiguration;
575 | buildSettings = {
576 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
577 | CODE_SIGN_ENTITLEMENTS = ZYDMonitorDemo/ZYDMonitorDemo.entitlements;
578 | CODE_SIGN_IDENTITY = "iPhone Developer";
579 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
580 | INFOPLIST_FILE = ZYDMonitorDemo/Info.plist;
581 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
582 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
583 | PRODUCT_BUNDLE_IDENTIFIER = com.zyd.ZYDMonitorDemo1;
584 | PRODUCT_NAME = "$(TARGET_NAME)";
585 | PROVISIONING_PROFILE = "";
586 | };
587 | name = Release;
588 | };
589 | 16E7BACA1BFA651700148E3D /* Debug */ = {
590 | isa = XCBuildConfiguration;
591 | buildSettings = {
592 | BUNDLE_LOADER = "$(TEST_HOST)";
593 | INFOPLIST_FILE = ZYDMonitorDemoTests/Info.plist;
594 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
595 | PRODUCT_BUNDLE_IDENTIFIER = com.zyd.ZYDMonitorDemoTests;
596 | PRODUCT_NAME = "$(TARGET_NAME)";
597 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ZYDMonitorDemo.app/ZYDMonitorDemo";
598 | };
599 | name = Debug;
600 | };
601 | 16E7BACB1BFA651700148E3D /* Release */ = {
602 | isa = XCBuildConfiguration;
603 | buildSettings = {
604 | BUNDLE_LOADER = "$(TEST_HOST)";
605 | INFOPLIST_FILE = ZYDMonitorDemoTests/Info.plist;
606 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
607 | PRODUCT_BUNDLE_IDENTIFIER = com.zyd.ZYDMonitorDemoTests;
608 | PRODUCT_NAME = "$(TARGET_NAME)";
609 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ZYDMonitorDemo.app/ZYDMonitorDemo";
610 | };
611 | name = Release;
612 | };
613 | 16E7BACD1BFA651700148E3D /* Debug */ = {
614 | isa = XCBuildConfiguration;
615 | buildSettings = {
616 | INFOPLIST_FILE = ZYDMonitorDemoUITests/Info.plist;
617 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
618 | PRODUCT_BUNDLE_IDENTIFIER = com.zyd.ZYDMonitorDemoUITests;
619 | PRODUCT_NAME = "$(TARGET_NAME)";
620 | TEST_TARGET_NAME = ZYDMonitorDemo;
621 | USES_XCTRUNNER = YES;
622 | };
623 | name = Debug;
624 | };
625 | 16E7BACE1BFA651700148E3D /* Release */ = {
626 | isa = XCBuildConfiguration;
627 | buildSettings = {
628 | INFOPLIST_FILE = ZYDMonitorDemoUITests/Info.plist;
629 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
630 | PRODUCT_BUNDLE_IDENTIFIER = com.zyd.ZYDMonitorDemoUITests;
631 | PRODUCT_NAME = "$(TARGET_NAME)";
632 | TEST_TARGET_NAME = ZYDMonitorDemo;
633 | USES_XCTRUNNER = YES;
634 | };
635 | name = Release;
636 | };
637 | 16E7BAE31BFA651700148E3D /* Debug */ = {
638 | isa = XCBuildConfiguration;
639 | buildSettings = {
640 | CODE_SIGN_ENTITLEMENTS = ZYDMonitor/ZYDMonitor.entitlements;
641 | CODE_SIGN_IDENTITY = "iPhone Developer";
642 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
643 | INFOPLIST_FILE = ZYDMonitor/Info.plist;
644 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
645 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
646 | PRODUCT_BUNDLE_IDENTIFIER = com.zyd.ZYDMonitorDemo1.ZYDMonitor;
647 | PRODUCT_NAME = "$(TARGET_NAME)";
648 | PROVISIONING_PROFILE = "";
649 | SKIP_INSTALL = YES;
650 | };
651 | name = Debug;
652 | };
653 | 16E7BAE41BFA651700148E3D /* Release */ = {
654 | isa = XCBuildConfiguration;
655 | buildSettings = {
656 | CODE_SIGN_ENTITLEMENTS = ZYDMonitor/ZYDMonitor.entitlements;
657 | CODE_SIGN_IDENTITY = "iPhone Developer";
658 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
659 | INFOPLIST_FILE = ZYDMonitor/Info.plist;
660 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
661 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
662 | PRODUCT_BUNDLE_IDENTIFIER = com.zyd.ZYDMonitorDemo1.ZYDMonitor;
663 | PRODUCT_NAME = "$(TARGET_NAME)";
664 | PROVISIONING_PROFILE = "";
665 | SKIP_INSTALL = YES;
666 | };
667 | name = Release;
668 | };
669 | /* End XCBuildConfiguration section */
670 |
671 | /* Begin XCConfigurationList section */
672 | 16E7BA941BFA651700148E3D /* Build configuration list for PBXProject "ZYDMonitorDemo" */ = {
673 | isa = XCConfigurationList;
674 | buildConfigurations = (
675 | 16E7BAC41BFA651700148E3D /* Debug */,
676 | 16E7BAC51BFA651700148E3D /* Release */,
677 | );
678 | defaultConfigurationIsVisible = 0;
679 | defaultConfigurationName = Release;
680 | };
681 | 16E7BAC61BFA651700148E3D /* Build configuration list for PBXNativeTarget "ZYDMonitorDemo" */ = {
682 | isa = XCConfigurationList;
683 | buildConfigurations = (
684 | 16E7BAC71BFA651700148E3D /* Debug */,
685 | 16E7BAC81BFA651700148E3D /* Release */,
686 | );
687 | defaultConfigurationIsVisible = 0;
688 | defaultConfigurationName = Release;
689 | };
690 | 16E7BAC91BFA651700148E3D /* Build configuration list for PBXNativeTarget "ZYDMonitorDemoTests" */ = {
691 | isa = XCConfigurationList;
692 | buildConfigurations = (
693 | 16E7BACA1BFA651700148E3D /* Debug */,
694 | 16E7BACB1BFA651700148E3D /* Release */,
695 | );
696 | defaultConfigurationIsVisible = 0;
697 | defaultConfigurationName = Release;
698 | };
699 | 16E7BACC1BFA651700148E3D /* Build configuration list for PBXNativeTarget "ZYDMonitorDemoUITests" */ = {
700 | isa = XCConfigurationList;
701 | buildConfigurations = (
702 | 16E7BACD1BFA651700148E3D /* Debug */,
703 | 16E7BACE1BFA651700148E3D /* Release */,
704 | );
705 | defaultConfigurationIsVisible = 0;
706 | defaultConfigurationName = Release;
707 | };
708 | 16E7BAE21BFA651700148E3D /* Build configuration list for PBXNativeTarget "ZYDMonitor" */ = {
709 | isa = XCConfigurationList;
710 | buildConfigurations = (
711 | 16E7BAE31BFA651700148E3D /* Debug */,
712 | 16E7BAE41BFA651700148E3D /* Release */,
713 | );
714 | defaultConfigurationIsVisible = 0;
715 | defaultConfigurationName = Release;
716 | };
717 | /* End XCConfigurationList section */
718 | };
719 | rootObject = 16E7BA911BFA651700148E3D /* Project object */;
720 | }
721 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo.xcodeproj/project.xcworkspace/xcuserdata/zyd.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alwaysDB/ZYDMonitor/f87fcd76c9927057dd1c5a5b65487cd000277d68/ZYDMonitorDemo/ZYDMonitorDemo.xcodeproj/project.xcworkspace/xcuserdata/zyd.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo.xcodeproj/xcuserdata/zyd.xcuserdatad/xcschemes/ZYDMonitor.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
6 |
9 |
10 |
16 |
22 |
23 |
24 |
30 |
36 |
37 |
38 |
39 |
40 |
45 |
46 |
47 |
48 |
54 |
55 |
56 |
57 |
58 |
59 |
70 |
72 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
92 |
98 |
99 |
100 |
101 |
103 |
104 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo.xcodeproj/xcuserdata/zyd.xcuserdatad/xcschemes/ZYDMonitorDemo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo.xcodeproj/xcuserdata/zyd.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | ZYDMonitor.xcscheme
8 |
9 | orderHint
10 | 1
11 |
12 | ZYDMonitorDemo.xcscheme
13 |
14 | orderHint
15 | 0
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | 16E7BA981BFA651700148E3D
21 |
22 | primary
23 |
24 |
25 | 16E7BAB11BFA651700148E3D
26 |
27 | primary
28 |
29 |
30 | 16E7BABC1BFA651700148E3D
31 |
32 | primary
33 |
34 |
35 | 16E7BAD21BFA651700148E3D
36 |
37 | primary
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // ZYDMonitorDemo
4 | //
5 | // Created by 朱耀东 on 15/11/16.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // ZYDMonitorDemo
4 | //
5 | // Created by 朱耀东 on 15/11/16.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/Assets.xcassets/snow.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "雪花.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/Assets.xcassets/snow.imageset/雪花.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alwaysDB/ZYDMonitor/f87fcd76c9927057dd1c5a5b65487cd000277d68/ZYDMonitorDemo/ZYDMonitorDemo/Assets.xcassets/snow.imageset/雪花.png
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/UIView+Category.h:
--------------------------------------------------------------------------------
1 |
2 | #import
3 |
4 | @interface UIView (Category)
5 | @property (nonatomic, assign) CGFloat x;
6 | @property (nonatomic, assign) CGFloat y;
7 | @property (nonatomic, assign) CGFloat centerX;
8 | @property (nonatomic, assign) CGFloat centerY;
9 | @property (nonatomic, assign) CGFloat width;
10 | @property (nonatomic, assign) CGFloat height;
11 | @property (nonatomic, assign) CGSize size;
12 | @property (nonatomic, assign) CGPoint origin;
13 | @end
14 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/UIView+Category.m:
--------------------------------------------------------------------------------
1 |
2 | #import "UIView+Category.h"
3 |
4 | @implementation UIView (Category)
5 | #pragma mark set方法
6 | - (void)setX:(CGFloat)x
7 | {
8 | CGRect frame = self.frame;
9 | frame.origin.x = x;
10 | self.frame = frame;
11 | }
12 |
13 | - (void)setY:(CGFloat)y
14 | {
15 | CGRect frame = self.frame;
16 | frame.origin.y = y;
17 | self.frame = frame;
18 | }
19 |
20 | - (void)setCenterX:(CGFloat)centerX
21 | {
22 | CGPoint center = self.center;
23 | center.x = centerX;
24 | self.center = center;
25 | }
26 |
27 | - (void)setCenterY:(CGFloat)centerY
28 | {
29 | CGPoint center = self.center;
30 | center.y = centerY;
31 | self.center = center;
32 | }
33 |
34 | - (void)setWidth:(CGFloat)width
35 | {
36 | CGRect frame = self.frame;
37 | frame.size.width = width;
38 | self.frame = frame;
39 | }
40 |
41 | - (void)setHeight:(CGFloat)height
42 | {
43 | CGRect frame = self.frame;
44 | frame.size.height = height;
45 | self.frame = frame;
46 | }
47 |
48 | - (void)setSize:(CGSize)size
49 | {
50 | CGRect frame = self.frame;
51 | frame.size = size;
52 | self.frame = frame;
53 | }
54 |
55 | - (void)setOrigin:(CGPoint)origin
56 | {
57 | CGRect frame = self.frame;
58 | frame.origin = origin;
59 | self.frame = frame;
60 | }
61 |
62 | #pragma mark get方法
63 | - (CGFloat)x
64 | {
65 | return self.frame.origin.x;
66 | }
67 |
68 | - (CGFloat)y
69 | {
70 | return self.frame.origin.y;
71 | }
72 |
73 | - (CGFloat)centerX
74 | {
75 | return self.center.x;
76 | }
77 |
78 | - (CGFloat)centerY
79 | {
80 | return self.center.y;
81 | }
82 |
83 | - (CGFloat)height
84 | {
85 | return self.frame.size.height;
86 | }
87 |
88 | - (CGFloat)width
89 | {
90 | return self.frame.size.width;
91 | }
92 |
93 | - (CGSize)size
94 | {
95 | return self.frame.size;
96 | }
97 |
98 | - (CGPoint)origin
99 | {
100 | return self.frame.origin;
101 | }
102 | @end
103 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // ZYDMonitorDemo
4 | //
5 | // Created by 朱耀东 on 15/11/16.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // ZYDMonitor
4 | //
5 | // Created by 朱耀东 on 15/11/17.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import
11 | #import
12 | #include
13 | #include
14 |
15 | #import "UIView+Category.h"
16 |
17 | @interface ViewController ()
18 |
19 | @end
20 |
21 | @implementation ViewController
22 |
23 | - (void)snowWithPoint:(CGPoint)point {
24 | UIImageView *snowView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"snow"]];
25 | snowView.center = point;
26 | [self.view addSubview:snowView];
27 | float randomY = (arc4random() % 300) + 100;
28 | float randomX = (arc4random() % 40) + 40;
29 |
30 | [UIView animateWithDuration:1.8 animations:^{
31 | snowView.y += randomY;
32 | snowView.x -= randomX;
33 | snowView.alpha = 0;
34 | } completion:^(BOOL finished) {
35 | [snowView removeFromSuperview];
36 | }];
37 | }
38 |
39 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
40 | UITouch *touch = touches.anyObject;
41 | CGPoint location = [touch locationInView:touch.view];
42 |
43 | [self snowWithPoint:location];
44 | }
45 |
46 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
47 | UITouch *touch = touches.anyObject;
48 |
49 | CGPoint point = [touch locationInView:self.view];
50 |
51 | [self snowWithPoint:point];
52 | }
53 |
54 | - (UIStatusBarStyle)preferredStatusBarStyle {
55 | return UIStatusBarStyleLightContent;
56 | }
57 |
58 | - (void)viewDidLoad {
59 | [super viewDidLoad];
60 |
61 | // UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"show"]];
62 | // imageView.frame = self.view.frame;
63 | // [self.view addSubview:imageView];
64 | // Do any additional setup after loading the view, typically from a nib.
65 |
66 | // // 空闲内存
67 | // double availableMemory = [self availableMemory];
68 | // // 已占用内存百分比
69 | // double preMemory = availableMemory / ([self usedMemory] + availableMemory) * 100;
70 | // // 可用磁盘容量
71 | // double availableDiskSize = [self getAvailableDiskSize];
72 | // // 总磁盘容量
73 | // double totalDiskSize = [self getTotalDiskSize];
74 | // // 可用磁盘百分比
75 | // double preDisk = availableDiskSize / totalDiskSize * 100;
76 | //
77 | // NSLog(@"\n 空闲内存:%.2f\n 已占用内存:%.2f%% \n 可用磁盘容量:%.2f \n 可用磁盘百分比:%.2f%%", availableMemory, preMemory, availableDiskSize, preDisk);
78 | //
79 | // [[NSUserDefaults standardUserDefaults] setValue:[NSString stringWithFormat:@"%f", availableMemory] forKey:@"availableMemory"];
80 | }
81 |
82 | //// 获取当前设备可用内存(单位:MB)
83 | //- (double)availableMemory
84 | //{
85 | // vm_statistics_data_t vmStats;
86 | // mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
87 | // kern_return_t kernReturn = host_statistics(mach_host_self(),
88 | // HOST_VM_INFO,
89 | // (host_info_t)&vmStats,
90 | // &infoCount);
91 | //
92 | // if (kernReturn != KERN_SUCCESS) {
93 | // return NSNotFound;
94 | // }
95 | //
96 | // return ((vm_page_size *vmStats.free_count) / 1024.0) / 1024.0;
97 | //}
98 | //
99 | //// 获取当前任务所占用的内存(单位:MB)
100 | //- (double)usedMemory
101 | //{
102 | // task_basic_info_data_t taskInfo;
103 | // mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT;
104 | // kern_return_t kernReturn = task_info(mach_task_self(),
105 | // TASK_BASIC_INFO,
106 | // (task_info_t)&taskInfo,
107 | // &infoCount);
108 | //
109 | // if (kernReturn != KERN_SUCCESS
110 | // ) {
111 | // return NSNotFound;
112 | // }
113 | //
114 | // return taskInfo.resident_size / 1024.0 / 1024.0;
115 | //}
116 | //
117 | //// 总磁盘容量
118 | //- (float)getTotalDiskSize
119 | //{
120 | // struct statfs buf;
121 | // unsigned long long freeSpace = -1;
122 | // if (statfs("/var", &buf) >= 0)
123 | // {
124 | // freeSpace = (unsigned long long)(buf.f_bsize * buf.f_blocks);
125 | // }
126 | // return freeSpace / 1024.0 / 1024.0;
127 | //}
128 | //
129 | //// 可用磁盘容量
130 | //-(float)getAvailableDiskSize
131 | //{
132 | // struct statfs buf;
133 | // unsigned long long freeSpace = -1;
134 | // if (statfs("/var", &buf) >= 0)
135 | // {
136 | // freeSpace = (unsigned long long)(buf.f_bsize * buf.f_bavail);
137 | // }
138 | // return freeSpace / 1024.0 / 1024.0;;
139 | //}
140 |
141 | //// 总内存
142 | //- (long long)getTotalMemorySize
143 | //{
144 | // return [NSProcessInfo processInfo].physicalMemory;
145 | //}
146 |
147 |
148 | - (void)didReceiveMemoryWarning {
149 | [super didReceiveMemoryWarning];
150 | // Dispose of any resources that can be recreated.
151 | }
152 |
153 | @end
154 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/ZYDMonitorDemo.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.application-groups
6 |
7 | group.ZYDMonitor
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // ZYDMonitorDemo
4 | //
5 | // Created by 朱耀东 on 15/11/16.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemoTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemoTests/ZYDMonitorDemoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // ZYDMonitorDemoTests.m
3 | // ZYDMonitorDemoTests
4 | //
5 | // Created by 朱耀东 on 15/11/16.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ZYDMonitorDemoTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation ZYDMonitorDemoTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemoUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ZYDMonitorDemo/ZYDMonitorDemoUITests/ZYDMonitorDemoUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // ZYDMonitorDemoUITests.m
3 | // ZYDMonitorDemoUITests
4 | //
5 | // Created by 朱耀东 on 15/11/16.
6 | // Copyright © 2015年 zyd. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ZYDMonitorDemoUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation ZYDMonitorDemoUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/image/show.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alwaysDB/ZYDMonitor/f87fcd76c9927057dd1c5a5b65487cd000277d68/image/show.png
--------------------------------------------------------------------------------