Skip to content

Commit

Permalink
Merge pull request #28 from sunilsharma08/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sunilsharma08 authored Jul 2, 2017
2 parents 6cb51d4 + 63cc361 commit 11d158b
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 75 deletions.
6 changes: 3 additions & 3 deletions AppUtilityExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
158 changes: 86 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<img src="https://github.com/sunilsharma08/AppUtility/blob/develop/alertView.gif" alt="Alert View" width="320" height="568"/>

```Swift
//Display alert view
let alertView = AUAlertView(title: "Alert title", message: "Message")
Expand Down Expand Up @@ -124,7 +55,6 @@ let fixImage:UIImage = image?.fixOrientation()
case snapBehaviour
case popUp
}

```
* ###### Enable/disable alertview dismiss on click of area outside alertview.
```Swift
Expand All @@ -145,6 +75,17 @@ let fixImage:UIImage = image?.fixOrientation()
```

## AUImageView (UIImageView Utility)
<table>
<tr>
<th>Black background</th>
<th>Blured Background</th>
</tr>
<tr>
<td><img src="https://github.com/sunilsharma08/AppUtility/blob/develop/imageView1.gif" alt="Alert View" width="320" height="568"/></td>
<td><img src="https://github.com/sunilsharma08/AppUtility/blob/develop/imageView2.gif" alt="Alert View" width="320" height="568"/></td>
</tr>
</table>

```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))
Expand Down Expand Up @@ -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.
Expand Down
Binary file added alertView.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imageView1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imageView2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 11d158b

Please sign in to comment.