Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jachobsen committed Oct 23, 2015
2 parents 47bfe4a + 8f25760 commit 83b40a2
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
xcuserdata
*.xccheckout
.DS_Store
Carthage
5 changes: 4 additions & 1 deletion .travis.yml
@@ -1,5 +1,8 @@
osx_image: beta-xcode6.3
osx_image: xcode7
language: objective-c
script:
- xctool -project NibDesignableDemo/NibDesignableDemo.xcodeproj -scheme NibDesignableDemo -sdk iphonesimulator
- xctool -project NibDesignableDemo/NibDesignableDemo.xcodeproj test -scheme NibDesignableDemo -sdk iphonesimulator
before_install:
- brew update
- brew uninstall xctool && brew install --HEAD xctool
2 changes: 1 addition & 1 deletion NibDesignable.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'NibDesignable'
s.version = '1.1.1'
s.version = '2.2.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'Elegant way of enabling IBDesignable on your nib-based views'
s.homepage = 'https://github.com/mbogh/NibDesignable'
Expand Down
60 changes: 60 additions & 0 deletions NibDesignable.swift
Expand Up @@ -107,3 +107,63 @@ public class NibDesignableTableViewCell: UITableViewCell {
self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
}
}

@IBDesignable
public class NibDesignableControl: UIControl {

// MARK: - Initializer
override public init(frame: CGRect) {
super.init(frame: frame)
self.setupNib()
}

// MARK: - NSCoding
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.setupNib()
}

// MARK: - Nib loading

/**
Called in init(frame:) and init(aDecoder:) to load the nib and add it as a subview.
*/
private func setupNib() {
let view = self.loadNib()
self.addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
let bindings = ["view": view]
self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
}
}

@IBDesignable
public class NibDesignableCollectionViewCell: UICollectionViewCell {

// MARK: - Initializer
override public init(frame: CGRect) {
super.init(frame: frame)
self.setupNib()
}

// MARK: - NSCoding
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.setupNib()
}

// MARK: - Nib loading

/**
Called in init(frame:) and init(aDecoder:) to load the nib and add it as a subview.
*/
private func setupNib() {
let view = self.loadNib()
self.contentView.addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
let bindings = ["view": view]
self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
self.contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
}
}
3 changes: 3 additions & 0 deletions NibDesignableDemo/NibDesignableDemo.xcodeproj/project.pbxproj
Expand Up @@ -184,6 +184,8 @@
5AD66C33198C06A70006A638 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0600;
ORGANIZATIONNAME = "Morten Bøgh";
TargetAttributes = {
Expand Down Expand Up @@ -446,6 +448,7 @@
5AD7CA421A6152F5002E66A8 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="14A388a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand Down
Expand Up @@ -39,7 +39,7 @@ public class ProfileAvatarView: NibDesignable {
let size = self.profileImage.size
let rect = CGRectMake(0, 0, size.width, size.height)
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
var path = UIBezierPath(ovalInRect: rect)
let path = UIBezierPath(ovalInRect: rect)
path.addClip()
self.profileImage.drawInRect(rect)

Expand All @@ -51,7 +51,7 @@ public class ProfileAvatarView: NibDesignable {

// MARK: Interface Builder
override public func prepareForInterfaceBuilder() {
if count(self.name) == 0 {
if self.name.utf8.count == 0 {
self.name = "John Appleseed"
}

Expand Down
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -47,6 +47,18 @@ Nib Designable is released under an MIT license. See LICENSE for more informatio

## Release Notes

Version 2.2.0

- `UICollectionViewCell` support added by @pyankoff

Version 2.1.0

- `UIControl` support added by @illaz

Version 2.0.0

- Swift 2.0 for everyone, thanks to @bjarkehs

Version 1.1.1

- Fixed minor issue with `UITableViewCell`
Expand Down

0 comments on commit 83b40a2

Please sign in to comment.