Skip to content

Commit

Permalink
Merge branch 'feature/set_image'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaoj committed Dec 6, 2015
2 parents 9417291 + 7de4304 commit 3be98f0
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 17 deletions.
2 changes: 1 addition & 1 deletion BSImagePicker.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "BSImagePicker"
s.version = "2.0.0"
s.version = "2.1.0"
s.summary = "BSImagePicker is a multiple image picker for iOS 8. UIImagePickerController replacement"
s.description = <<-DESC
A mix between the native iOS 8 gallery and facebooks image picker. Allows you to preview and select multiple images.
Expand Down
6 changes: 6 additions & 0 deletions Example/BSImagePicker/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
23 changes: 23 additions & 0 deletions Example/BSImagePicker/Images.xcassets/chat.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "chat.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Example/BSImagePicker/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ViewController: UIViewController {
@IBAction func showCustomImagePicker(sender: UIButton) {
let vc = BSImagePickerViewController()
vc.maxNumberOfSelections = 6
vc.takePhotoIcon = UIImage(named: "chat")

vc.albumButton.tintColor = UIColor.greenColor()
vc.cancelButton.tintColor = UIColor.redColor()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions Pod/Assets/CameraCell.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="15A282b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CameraCell" customModule="BSImagePicker" customModuleProvider="target"/>
Expand All @@ -19,7 +18,7 @@
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="add_photo.png" translatesAutoresizingMaskIntoConstraints="NO" id="qvQ-jD-B52">
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="qvQ-jD-B52">
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
<animations/>
</imageView>
Expand All @@ -46,7 +45,4 @@
<point key="canvasLocation" x="82" y="280"/>
</collectionViewCell>
</objects>
<resources>
<image name="add_photo.png" width="25" height="23"/>
</resources>
</document>
10 changes: 7 additions & 3 deletions Pod/Assets/PhotoCell.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="PhotoCell" customModule="BSImagePicker" customModuleProvider="target"/>
Expand All @@ -16,22 +15,27 @@
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="eql-VY-cc4">
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
<animations/>
</imageView>
<view alpha="0.0" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vrZ-cc-3iN">
<rect key="frame" x="0.0" y="0.0" width="100" height="100"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<view alpha="0.0" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZWL-2w-R4Y" customClass="SelectionView" customModule="BSImagePicker">
<rect key="frame" x="71" y="71" width="25" height="25"/>
<animations/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="25" id="KmA-hg-Sja"/>
<constraint firstAttribute="width" constant="25" id="Sed-si-Khu"/>
</constraints>
</view>
</subviews>
<animations/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<animations/>
<constraints>
<constraint firstItem="vrZ-cc-3iN" firstAttribute="leading" secondItem="Wnb-Ja-sAy" secondAttribute="leading" id="1k6-ja-XtL"/>
<constraint firstItem="eql-VY-cc4" firstAttribute="leading" secondItem="Wnb-Ja-sAy" secondAttribute="leading" id="6Yj-56-Ajf"/>
Expand Down
9 changes: 9 additions & 0 deletions Pod/Classes/Controller/BSImagePickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ public final class BSImagePickerViewController : UINavigationController, BSImage
}
}

public var takePhotoIcon: UIImage? {
get {
return settings.takePhotoIcon
}
set {
settings.takePhotoIcon = newValue
}
}

// MARK: Buttons
/**
Cancel button
Expand Down
5 changes: 4 additions & 1 deletion Pod/Classes/Model/CameraCollectionViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ final class CameraCollectionViewDataSource: NSObject, UICollectionViewDataSource
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
return collectionView.dequeueReusableCellWithReuseIdentifier(cameraCellIdentifier, forIndexPath: indexPath)
let cameraCell = collectionView.dequeueReusableCellWithReuseIdentifier(cameraCellIdentifier, forIndexPath: indexPath) as! CameraCell
cameraCell.takePhotoIcon = settings.takePhotoIcon

return cameraCell
}

func registerCellIdentifiersForCollectionView(collectionView: UICollectionView?) {
Expand Down
2 changes: 2 additions & 0 deletions Pod/Classes/Model/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ final class Settings : BSImagePickerSettings {
}

var takePhotos: Bool = false

var takePhotoIcon: UIImage? = UIImage(named: "add_photo", inBundle: BSImagePickerViewController.bundle, compatibleWithTraitCollection: nil)
}
6 changes: 6 additions & 0 deletions Pod/Classes/Protocol/BSImagePickerSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ public protocol BSImagePickerSettings {
Toggle take photos
*/
var takePhotos: Bool { get set }

/**
Icon to show in take photo cell.
If you use a black image tint color will be applied to it.
*/
var takePhotoIcon: UIImage? { get set }
}
11 changes: 8 additions & 3 deletions Pod/Classes/View/CameraCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import AVFoundation
final class CameraCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var cameraBackground: UIView!
var takePhotoIcon: UIImage? {
didSet {
imageView.image = takePhotoIcon

// Apply tint to image
imageView.image = imageView.image?.imageWithRenderingMode(.AlwaysTemplate)
}
}

var session: AVCaptureSession?
var captureLayer: AVCaptureVideoPreviewLayer?
Expand All @@ -22,9 +30,6 @@ final class CameraCell: UICollectionViewCell {
override func awakeFromNib() {
super.awakeFromNib()

// Apply tint to image
imageView.image = imageView.image?.imageWithRenderingMode(.AlwaysTemplate)

// Don't trigger camera access for the background
guard AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) == .Authorized else {
return
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ BSImagePicker is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod "BSImagePicker", "~> 2.0"
pod "BSImagePicker", "~> 2.1"
```

## Author
Expand Down

0 comments on commit 3be98f0

Please sign in to comment.