diff --git a/Demo/Classes/ViewController.h b/Demo/Classes/ViewController.h index d081bc3..3fecf92 100644 --- a/Demo/Classes/ViewController.h +++ b/Demo/Classes/ViewController.h @@ -12,6 +12,7 @@ - (IBAction)showWithImage; - (IBAction)showWithImageStatus; +- (IBAction)showWithStatusDuration:(id)sender; @end diff --git a/Demo/Classes/ViewController.m b/Demo/Classes/ViewController.m index acbc314..dcf1dda 100644 --- a/Demo/Classes/ViewController.m +++ b/Demo/Classes/ViewController.m @@ -27,4 +27,8 @@ - (void)showWithImageStatus { [SVStatusHUD showWithImage:[UIImage imageNamed:@"wifi"] status:@"Connected"]; } +- (IBAction)showWithStatusDuration:(id)sender { + [SVStatusHUD showWithStatus:@"Add another api to support case only have status." duration:2.0]; +} + @end diff --git a/Demo/ViewController.xib b/Demo/ViewController.xib index 274f97e..a8f1767 100644 --- a/Demo/ViewController.xib +++ b/Demo/ViewController.xib @@ -1,31 +1,28 @@ - + - 1280 - 11C74 - 1938 - 1138.23 - 567.00 + 2048 + 13E28 + 6205 + 1265.21 + 698.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 933 + 6198 - - YES + IBProxyObject - IBUIView IBUIButton - - - YES + IBUIView + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin - + PluginDependencyRecalculationVersion - - YES + IBFilesOwner IBCocoaTouchFramework @@ -37,29 +34,28 @@ 292 - - YES + 293 {{30, 141}, {260, 44}} - + NO IBCocoaTouchFramework 0 0 1 - showWithImage:status: + + 1 + MC4xOTYwNzg0MzE0IDAuMzA5ODAzOTIxNiAwLjUyMTU2ODYyNzUAA + 3 MQA - - 1 - MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - + showWithImage:status: 3 MC41AA @@ -88,17 +84,39 @@ 0 0 1 - showWithImage: + - - 1 - MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA - + showWithImage: - + + + 292 + {{58, 208}, {205, 44}} + + + NO + IBCocoaTouchFramework + 0 + 0 + 1 + + + showWithStatus:duration: + + + 2 + 15 + + + HelveticaNeue-Bold + 15 + 16 + + + {320, 460} @@ -107,12 +125,15 @@ 2 MC45MDE5NjA4NDk4IDAuOTAxOTYwODQ5OCAwLjkwMTk2MDg0OTgAA + + IBUISimulatedFreeformSizeMetricsSentinel + Freeform + IBCocoaTouchFramework - + - - YES + view @@ -139,15 +160,21 @@ 28 - + + + showWithStatusDuration: + + + 7 + + 30 + + - - YES + 0 - - YES - + @@ -156,128 +183,383 @@ File's Owner + + + + + -2 + + + + + 8 - - YES + - + + + + + + + + + + + + 1 + {0, 0} + + + + + + + + 2 + {320, 460} + + + + + + + + + + + + + + + + + + + + + + + + ibDesignableContentView.ibShadowedSubviews + + + + + + + 9 + + + + + + + + + + + + + + 1 + {30, 72} + + + + + + + + 2 + {260, 44} + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + 1 + {30, 141} + + + + + + + + 2 + {260, 44} + + + + + + + + + + + + + + + + + + + + + + + + - - - - YES - - YES - -1.CustomClassName - -1.IBPluginDependency - -2.CustomClassName - -2.IBPluginDependency - 10.IBPluginDependency - 8.IBPluginDependency - 9.IBPluginDependency - - - YES - ViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UIResponder - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - YES - - + + 29 + + + + + + + + + + + + + + + + 1 + {58, 208} + + + + + + + + 2 + {205, 44} + + + + + + + + + + + + + + + + + + + + + + + + + + + + ViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + - - YES - - - + - 28 + 30 - - YES + ViewController UIViewController - - YES - - YES - showWithImage - showWithImageStatus + + id + id + id + + + + showWithImage + id + + + showWithImageStatus + id - - YES - id - id + + showWithStatusDuration: + id + + + IBProjectSource + ../Classes/ViewController.h + + + + ViewController + + showWithStatusDuration: + id - YES - - YES - showWithImage - showWithImageStatus - - - YES - - showWithImage - id - - - showWithImageStatus - id - + showWithStatusDuration: + + showWithStatusDuration: + id IBProjectSource - ./Classes/ViewController.h + ../Classes/ViewController.m - + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIGestureRecognizer + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIGestureRecognizer.h + + + + UIResponder + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + 0 IBCocoaTouchFramework - - com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - - + NO com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 - + YES 3 - 933 diff --git a/SVStatusHUD/SVStatusHUD.h b/SVStatusHUD/SVStatusHUD.h index dcdbb88..e657b99 100644 --- a/SVStatusHUD/SVStatusHUD.h +++ b/SVStatusHUD/SVStatusHUD.h @@ -13,6 +13,7 @@ + (void)showWithImage:(UIImage*)image; + (void)showWithImage:(UIImage*)image status:(NSString*)string; ++ (void)showWithStatus:(NSString*)string duration:(NSTimeInterval)duration; + (void)showWithImage:(UIImage*)image status:(NSString*)string duration:(NSTimeInterval)duration; @end diff --git a/SVStatusHUD/SVStatusHUD.m b/SVStatusHUD/SVStatusHUD.m index f000c2c..762890b 100644 --- a/SVStatusHUD/SVStatusHUD.m +++ b/SVStatusHUD/SVStatusHUD.m @@ -81,6 +81,11 @@ + (void)showWithImage:(UIImage*)image status:(NSString*)string { [SVStatusHUD showWithImage:image status:string duration:SVStatusHUDVisibleDuration]; } ++ (void)showWithStatus:(NSString*)string duration:(NSTimeInterval)duration +{ + [SVStatusHUD showWithImage:nil status:string duration:duration]; +} + + (void)showWithImage:(UIImage*)image status:(NSString*)string duration:(NSTimeInterval)duration { [[SVStatusHUD sharedView] showWithImage:image status:string duration:duration]; } @@ -106,22 +111,39 @@ - (void)setStatus:(NSString *)string { CGFloat hudWidth = 160; CGFloat hudHeight = 160; - + self.hudView.bounds = CGRectMake(0, 0, hudWidth, hudHeight); - if(!string) - self.imageView.center = CGPointMake(self.hudView.bounds.size.width/2, self.hudView.bounds.size.height/2); - else - self.imageView.center = CGPointMake(self.hudView.bounds.size.width/2, 70); - - self.stringLabel.hidden = NO; - self.stringLabel.text = string; + self.stringLabel.hidden = NO; + self.stringLabel.text = string; + + if( string == nil ){ + if ( imageView != nil ){ + self.imageView.center = CGPointMake(hudWidth/2, hudHeight/2); + } + }else{ + if ( imageView == nil ){ + stringLabel.frame = CGRectMake(10, 0, hudWidth-10, hudHeight); + }else{ + self.imageView.center = CGPointMake(hudWidth/2, 70); + stringLabel.frame = CGRectMake(0, 123, 160, 20); + } + } + } - (void)showWithImage:(UIImage *)image status:(NSString *)string duration:(NSTimeInterval)duration { - self.imageView.image = image; + if ( image == nil ){ + if ( imageView != nil ){ + [imageView removeFromSuperview]; + [imageView release]; + imageView = nil; + } + }else{ + self.imageView.image = image; + } [self setStatus:string]; [self.overlayWindow setHidden:NO]; diff --git a/TYStatusHUD.podspec b/TYStatusHUD.podspec new file mode 100644 index 0000000..2a020ef --- /dev/null +++ b/TYStatusHUD.podspec @@ -0,0 +1,132 @@ +# +# Be sure to run `pod spec lint SVStatusHUD2.podspec' to ensure this is a +# valid spec and to remove all comments including this before submitting the spec. +# +# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html +# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ +# + +Pod::Spec.new do |s| + + # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # These will help people to find your library, and whilst it + # can feel like a chore to fill in it's definitely to your advantage. The + # summary should be tweet-length, and the description more in depth. + # + + s.name = "TYStatusHUD" + s.version = "0.2" + s.summary = "TYStatusHUD mimics the HUD shown on orientation lock, mute and volume change on iOS." + + s.description = <<-DESC + TYStatusHUD mimics the HUD shown on orientation lock, mute and volume change on iOS. It should only be used in response to hardware or other important notifications (for instance when an accessory is detected by your app). + forked from SVStatusHUD + DESC + + s.homepage = "https://github.com/northwind/SVStatusHUD" + # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" + + + # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Licensing your code is important. See http://choosealicense.com for more info. + # CocoaPods will detect a license file if there is a named LICENSE* + # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. + # + + s.license = "MIT" + # s.license = { :type => "MIT", :file => "FILE_LICENSE" } + + + # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the authors of the library, with email addresses. Email addresses + # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also + # accepts just a name if you'd rather not provide an email address. + # + # Specify a social_media_url where others can refer to, for example a twitter + # profile URL. + # + + s.author = { "northwind" => "norristong_x@qq.com" } + # Or just: s.author = "northwind" + # s.authors = { "northwind" => "norristong_x@qq.com" } + # s.social_media_url = "http://twitter.com/northwind" + + # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If this Pod runs only on iOS or OS X, then specify the platform and + # the deployment target. You can optionally include the target after the platform. + # + + s.platform = :ios + # s.platform = :ios, "5.0" + + # When using multiple platforms + # s.ios.deployment_target = "5.0" + # s.osx.deployment_target = "10.7" + + + # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the location from where the source should be retrieved. + # Supports git, hg, bzr, svn and HTTP. + # + + s.source = { :git => "https://github.com/northwind/SVStatusHUD.git", :tag => s.version.to_s } + + + # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # CocoaPods is smart about how it includes source code. For source files + # giving a folder will include any h, m, mm, c & cpp files. For header + # files it will include any header in the folder. + # Not including the public_header_files will make all headers public. + # + + s.source_files = "SVStatusHUD/*.{h,m}" + # s.exclude_files = "Classes/Exclude" + + # s.public_header_files = "Classes/**/*.h" + + + # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # A list of resources included with the Pod. These are copied into the + # target bundle with a build phase script. Anything else will be cleaned. + # You can preserve files from being cleaned, please don't preserve + # non-essential files like tests, examples and documentation. + # + + # s.resource = "icon.png" + # s.resources = "Resources/*.png" + + # s.preserve_paths = "FilesToSave", "MoreFilesToSave" + + + # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Link your library with frameworks, or libraries. Libraries do not include + # the lib prefix of their name. + # + + s.framework = "UIKit" + # s.frameworks = "SomeFramework", "AnotherFramework" + + # s.library = "iconv" + # s.libraries = "iconv", "xml2" + + + # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If your library depends on compiler flags you can set them in the xcconfig hash + # where they will only apply to your library. If you depend on other Podspecs + # you can include multiple dependencies to ensure it works. + + s.requires_arc = false + + # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } + # s.dependency "JSONKit", "~> 1.4" + +end