diff --git a/AppUtilityExample/ViewController.swift b/AppUtilityExample/ViewController.swift index 1646d65..c0fc4e7 100644 --- a/AppUtilityExample/ViewController.swift +++ b/AppUtilityExample/ViewController.swift @@ -120,7 +120,7 @@ class ViewController: UIViewController,UIScrollViewDelegate { let alertView = AUAlertView(title: "Alert title", message: "Message") //Customisation - alertView.alertViewAnimationType = .popUp + alertView.alertViewAnimationType = .snapBehaviour alertView.backgroundType = .blurEffectLight alertView.isPanGestureEnabled = true alertView.dismissOnBackgroundTouch = true @@ -133,8 +133,8 @@ class ViewController: UIViewController,UIScrollViewDelegate { let okButton = AUAlertAction(title: "Ok", style: .default) { (action) in print("Clicked on OK button") } - let other = AUAlertAction(title: "Other", style: .destructive) - alertView.addAction(other) + //let other = AUAlertAction(title: "Other", style: .destructive) + //alertView.addAction(other) alertView.addAction(cancelButton) alertView.addAction(okButton) alertView.show() diff --git a/README.md b/README.md index 74cf573..8531130 100644 --- a/README.md +++ b/README.md @@ -9,79 +9,10 @@ Some code snippets are taken from Stackoverflow, Github and some are added by m Just drag the folder "AppUtility" with the source files into your project. # Usage -## AUColor (UIColor Utility) -#### UIColor Extensions -```Swift -//Using direct RGB value no need to divide every time with 255.0 -UIColor.init(redValue: 199, greenValue: 165, blueValue: 247) - -//Getting color with hex value, default alpha value is 1.0 -UIColor.init(hex: 0xffffff) - -//Getting color with hex and alpha value -UIColor.init(hex:0xff0000, alpha:0.8) - -//Getting color with hex string -//Hex with alpha -UIColor.init(hexCode: "#ff0000ff") - -//Hex with no alpha (alpha will be 1.0) -UIColor.init(hexCode: "#ff0000") - -//Hex string in short form -UIColor.init(hexCode: "#f00") -``` - -## AUDate (Date Utility) -#### Date Extensions -```Swift -//Getting no. of years between two dates -let noOfYear = NSDate().yearsFrom(NSDate.init(timeIntervalSince1970: 3000000000)) - -//Getting no. of months between two dates -let noOfMonths = NSDate().monthsFrom(NSDate.init(timeIntervalSince1970: 3000000000)) - -//Getting no. of weeks between two dates -let noOfWeeks = NSDate().weeksFrom(NSDate.init(timeIntervalSince1970: 3000000000)) - -//Getting no. of days between two dates -let noOfDays = NSDate().daysFrom(NSDate.init(timeIntervalSince1970: 3000000000)) -//Getting no. of hours between two dates -let noOfHours = NSDate().hoursFrom(NSDate.init(timeIntervalSince1970: 3000000000)) - -//Getting no. of minutes between two dates -let noOfMin = NSDate().minutesFrom(NSDate.init(timeIntervalSince1970: 3000000000)) - -//Getting no. of seconds between two dates -let noOfSec = NSDate().secondsFrom(NSDate.init(timeIntervalSince1970: 3000000000)) - -//Getting no. of time between two dates e.g- 2s ago, 1M ago, etc. -let dateOffsets = NSDate().offsetFrom(NSDate.init(timeIntervalSince1970: 3000000000)) -``` - -## AUImage (UIImage Utility) -#### UIImage Extensions -```Swift -//Create a image of specified color and size -let image = UIImage.imageWithColor(UIColor.redColor(), size: CGSizeMake(100, 100)) - -//Create horizontal gradient color image -let image = UIImage.imageWithGradient([UIColor.redColor().CGColor,UIColor.yellowColor().CGColor], size: CGSizeMake(560, 400)) - -//Create vertical gradient color image -let image = UIImage.imageWithGradient([UIColor.redColor().CGColor,UIColor.yellowColor().CGColor], size: CGSizeMake(560, 400), verticalGradient: true) - -//Resizing image while maintaing aspect ratio -let resizedImage:UIImage = image?.resizeImage(CGSizeMake(200, 200)) - -//Compress image size(compression should be between 0.0 - 1.0) -let compressedImage:UIImage = image?.compressImage(0.5) - -//Fix for rotating image when using imagePicker -let fixImage:UIImage = image?.fixOrientation() -``` ## AUAlertView (Alert message Utility) +Alert View + ```Swift //Display alert view let alertView = AUAlertView(title: "Alert title", message: "Message") @@ -124,7 +55,6 @@ let fixImage:UIImage = image?.fixOrientation() case snapBehaviour case popUp } - ``` * ###### Enable/disable alertview dismiss on click of area outside alertview. ```Swift @@ -145,6 +75,17 @@ let fixImage:UIImage = image?.fixOrientation() ``` ## AUImageView (UIImageView Utility) + + + + + + + + + +
Black backgroundBlured Background
Alert ViewAlert View
+ ```Swift //AUImageView is subclass of UIImageView. Use this class to enable zoom in image view. let imageview = AUImageView(frame: CGRect(x: 20, y: 350, width: self.view.frame.size.width - 40, height: 200)) @@ -181,6 +122,79 @@ let fixImage:UIImage = image?.fixOrientation() public var enableImageZoom = false ``` +## AUColor (UIColor Utility) +#### UIColor Extensions +```Swift +//Using direct RGB value no need to divide every time with 255.0 +UIColor.init(redValue: 199, greenValue: 165, blueValue: 247) + +//Getting color with hex value, default alpha value is 1.0 +UIColor.init(hex: 0xffffff) + +//Getting color with hex and alpha value +UIColor.init(hex:0xff0000, alpha:0.8) + +//Getting color with hex string +//Hex with alpha +UIColor.init(hexCode: "#ff0000ff") + +//Hex with no alpha (alpha will be 1.0) +UIColor.init(hexCode: "#ff0000") + +//Hex string in short form +UIColor.init(hexCode: "#f00") +``` + +## AUDate (Date Utility) +#### Date Extensions +```Swift +//Getting no. of years between two dates +let noOfYear = NSDate().yearsFrom(NSDate.init(timeIntervalSince1970: 3000000000)) + +//Getting no. of months between two dates +let noOfMonths = NSDate().monthsFrom(NSDate.init(timeIntervalSince1970: 3000000000)) + +//Getting no. of weeks between two dates +let noOfWeeks = NSDate().weeksFrom(NSDate.init(timeIntervalSince1970: 3000000000)) + +//Getting no. of days between two dates +let noOfDays = NSDate().daysFrom(NSDate.init(timeIntervalSince1970: 3000000000)) + +//Getting no. of hours between two dates +let noOfHours = NSDate().hoursFrom(NSDate.init(timeIntervalSince1970: 3000000000)) + +//Getting no. of minutes between two dates +let noOfMin = NSDate().minutesFrom(NSDate.init(timeIntervalSince1970: 3000000000)) + +//Getting no. of seconds between two dates +let noOfSec = NSDate().secondsFrom(NSDate.init(timeIntervalSince1970: 3000000000)) + +//Getting no. of time between two dates e.g- 2s ago, 1M ago, etc. +let dateOffsets = NSDate().offsetFrom(NSDate.init(timeIntervalSince1970: 3000000000)) +``` + +## AUImage (UIImage Utility) +#### UIImage Extensions +```Swift +//Create a image of specified color and size +let image = UIImage.imageWithColor(UIColor.redColor(), size: CGSizeMake(100, 100)) + +//Create horizontal gradient color image +let image = UIImage.imageWithGradient([UIColor.redColor().CGColor,UIColor.yellowColor().CGColor], size: CGSizeMake(560, 400)) + +//Create vertical gradient color image +let image = UIImage.imageWithGradient([UIColor.redColor().CGColor,UIColor.yellowColor().CGColor], size: CGSizeMake(560, 400), verticalGradient: true) + +//Resizing image while maintaing aspect ratio +let resizedImage:UIImage = image?.resizeImage(CGSizeMake(200, 200)) + +//Compress image size(compression should be between 0.0 - 1.0) +let compressedImage:UIImage = image?.compressImage(0.5) + +//Fix for rotating image when using imagePicker +let fixImage:UIImage = image?.fixOrientation() +``` + ## AUDispatchQueueExtension (DispatchQueue Utility) ```Swift // This method will dispatch the `block` to self. diff --git a/alertView.gif b/alertView.gif new file mode 100644 index 0000000..92ce665 Binary files /dev/null and b/alertView.gif differ diff --git a/imageView1.gif b/imageView1.gif new file mode 100644 index 0000000..d2be9cb Binary files /dev/null and b/imageView1.gif differ diff --git a/imageView2.gif b/imageView2.gif new file mode 100644 index 0000000..32885ad Binary files /dev/null and b/imageView2.gif differ