فهرست منبع

Add custom class to display status messages

Felix Paul Kühne 12 سال پیش
والد
کامیت
1a895b91b8
3فایلهای تغییر یافته به همراه102 افزوده شده و 4 حذف شده
  1. 18 4
      AspenProject.xcodeproj/project.pbxproj
  2. 18 0
      AspenProject/VLCStatusLabel.h
  3. 66 0
      AspenProject/VLCStatusLabel.m

+ 18 - 4
AspenProject.xcodeproj/project.pbxproj

@@ -29,6 +29,7 @@
 		7D10BCA71743FE7B00DA7059 /* reset@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D10BC9D1743FE7B00DA7059 /* reset@2x.png */; };
 		7D10BCA81743FE7B00DA7059 /* speed.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D10BC9E1743FE7B00DA7059 /* speed.png */; };
 		7D10BCA91743FE7B00DA7059 /* speed@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D10BC9F1743FE7B00DA7059 /* speed@2x.png */; };
+		7D31CF091746AF09005997E0 /* VLCStatusLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D31CF081746AF09005997E0 /* VLCStatusLabel.m */; };
 		7D33D41617182615008AF0E0 /* VLCMovieViewController~ipad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D33D41517182615008AF0E0 /* VLCMovieViewController~ipad.xib */; };
 		7D6B07BC1716C9B8003280C4 /* AQGridView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D6B07A61716C9B8003280C4 /* AQGridView.m */; };
 		7D6B07BD1716C9B8003280C4 /* AQGridViewAnimatorItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D6B07AA1716C9B8003280C4 /* AQGridViewAnimatorItem.m */; };
@@ -118,6 +119,8 @@
 		7D10BC9D1743FE7B00DA7059 /* reset@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "reset@2x.png"; path = "Resources/reset@2x.png"; sourceTree = SOURCE_ROOT; };
 		7D10BC9E1743FE7B00DA7059 /* speed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = speed.png; path = Resources/speed.png; sourceTree = SOURCE_ROOT; };
 		7D10BC9F1743FE7B00DA7059 /* speed@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "speed@2x.png"; path = "Resources/speed@2x.png"; sourceTree = SOURCE_ROOT; };
+		7D31CF071746AF09005997E0 /* VLCStatusLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCStatusLabel.h; sourceTree = "<group>"; };
+		7D31CF081746AF09005997E0 /* VLCStatusLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCStatusLabel.m; sourceTree = "<group>"; };
 		7D33D41517182615008AF0E0 /* VLCMovieViewController~ipad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = "VLCMovieViewController~ipad.xib"; path = "Resources/VLCMovieViewController~ipad.xib"; sourceTree = SOURCE_ROOT; };
 		7D6B07A51716C9B8003280C4 /* AQGridView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AQGridView.h; path = ImportedSources/AQGridView/Classes/AQGridView.h; sourceTree = SOURCE_ROOT; };
 		7D6B07A61716C9B8003280C4 /* AQGridView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AQGridView.m; path = ImportedSources/AQGridView/Classes/AQGridView.m; sourceTree = SOURCE_ROOT; };
@@ -307,6 +310,19 @@
 			path = ../AspenProject;
 			sourceTree = "<group>";
 		};
+		7D31CF061746AEF2005997E0 /* UI Elements */ = {
+			isa = PBXGroup;
+			children = (
+				7DE480CF173FEA30003613E0 /* VLCCircularProgressIndicator.h */,
+				7DE480D0173FEA30003613E0 /* VLCCircularProgressIndicator.m */,
+				7DC87AEC17412A1F009DC250 /* VLCLinearProgressIndicator.h */,
+				7DC87AED17412A1F009DC250 /* VLCLinearProgressIndicator.m */,
+				7D31CF071746AF09005997E0 /* VLCStatusLabel.h */,
+				7D31CF081746AF09005997E0 /* VLCStatusLabel.m */,
+			);
+			name = "UI Elements";
+			sourceTree = "<group>";
+		};
 		7D6B07A31716C9A6003280C4 /* OBSlider */ = {
 			isa = PBXGroup;
 			children = (
@@ -402,10 +418,7 @@
 				7D6B07F61716D45B003280C4 /* VLCPlaylistGridView.m */,
 				A7DA16CF171083DF00D6FED9 /* VLCExternalDisplayController.h */,
 				A7DA16D0171083DF00D6FED9 /* VLCExternalDisplayController.m */,
-				7DE480CF173FEA30003613E0 /* VLCCircularProgressIndicator.h */,
-				7DE480D0173FEA30003613E0 /* VLCCircularProgressIndicator.m */,
-				7DC87AEC17412A1F009DC250 /* VLCLinearProgressIndicator.h */,
-				7DC87AED17412A1F009DC250 /* VLCLinearProgressIndicator.m */,
+				7D31CF061746AEF2005997E0 /* UI Elements */,
 				7DADC5601704FACC001DAC63 /* Imported */,
 				7DADC55C1704FAA8001DAC63 /* XIBs */,
 				A7924697170F0ED20036AAF2 /* Resources */,
@@ -624,6 +637,7 @@
 				7D6B07F71716D45C003280C4 /* VLCPlaylistGridView.m in Sources */,
 				7DE480D1173FEA30003613E0 /* VLCCircularProgressIndicator.m in Sources */,
 				7DC87AEE17412A1F009DC250 /* VLCLinearProgressIndicator.m in Sources */,
+				7D31CF091746AF09005997E0 /* VLCStatusLabel.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 18 - 0
AspenProject/VLCStatusLabel.h

@@ -0,0 +1,18 @@
+//
+//  VLCStatusLabel.h
+//  AspenProject
+//
+//  Created by Felix Paul Kühne on 17.05.13.
+//  Copyright (c) 2013 VideoLAN. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface VLCStatusLabel : UILabel
+{
+    NSTimer *_displayTimer;
+}
+
+- (void)showStatusMessage:(NSString *)message;
+
+@end

+ 66 - 0
AspenProject/VLCStatusLabel.m

@@ -0,0 +1,66 @@
+//
+//  VLCStatusLabel.m
+//  AspenProject
+//
+//  Created by Felix Paul Kühne on 17.05.13.
+//  Copyright (c) 2013 VideoLAN. All rights reserved.
+//
+
+#import "VLCStatusLabel.h"
+
+@implementation VLCStatusLabel
+
+- (void)showStatusMessage:(NSString *)message
+{
+    self.text = message;
+    [self setNeedsDisplay];
+    [self _toggleVisibility:NO];
+
+    _displayTimer = [NSTimer scheduledTimerWithTimeInterval:1.5
+                                                     target:self
+                                                   selector:@selector(_hideAgain)
+                                                   userInfo:nil
+                                                    repeats:NO];
+}
+
+- (void)_hideAgain
+{
+    [self _toggleVisibility:YES];
+    _displayTimer = nil;
+}
+
+- (void)_toggleVisibility:(BOOL)hidden
+{
+    CGFloat alpha = hidden? 0.0f: 1.0f;
+
+    if (!hidden) {
+        self.alpha = 0.0f;
+        self.hidden = NO;
+    }
+
+    void (^animationBlock)() = ^() {
+        self.alpha = alpha;
+    };
+
+    void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
+        self.hidden = hidden;
+    };
+
+    [UIView animateWithDuration:0.3f animations:animationBlock completion:completionBlock];
+}
+
+- (void)drawRect:(CGRect)rect
+{
+    self.backgroundColor = [UIColor clearColor];
+    CGContextClearRect(UIGraphicsGetCurrentContext(), rect);
+
+    UIColor *drawingColor = [UIColor colorWithWhite:.20 alpha:.7];
+    [drawingColor setFill];
+
+    UIBezierPath* bezierPath = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:rect.size.height / 2];
+    [bezierPath fill];
+
+    [super drawRect:rect];
+}
+
+@end