diff --git a/README.md b/README.md
index 144ef80..f60246b 100644
--- a/README.md
+++ b/README.md
@@ -50,7 +50,9 @@ http://www.clearsightstudio.com/insights/tutorial-make-youtube-video-app-rubymot
## Sample Apps
-[https://github.com/jamonholmgren/promotion-tutorial](https://github.com/jamonholmgren/promotion-tutorial)
+This is pretty bare-bones, but we'll be building it out as we go along.
+
+[https://github.com/jamonholmgren/promotion-demo](https://github.com/jamonholmgren/promotion-demo)
## Apps Built With ProMotion
@@ -250,6 +252,8 @@ set_nav_bar_right_button "Save", action: :save_something, type: UIBarButtonItemS
set_nav_bar_left_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
```
+If you pass an instance of a `UIImage`, the `UIBarButton` will automatically display with that image instead of text. *Don't forget retina and landscape versions of your image!*
+
## Opening and closing screens
If the user taps something and you want to open a new screen, it's easy. Just use `open` and pass in the screen class
@@ -290,7 +294,6 @@ class ProfileScreen < ProMotion::Screen
self.user # => some_user instance
end
end
-
```
Closing a screen is as easy as can be.
@@ -570,12 +573,14 @@ end
set_nav_bar_left_button(title, args = {}) |
Set a left nav bar button.
+ `title` can be a `String` or a `UIImage`.
|
| set_nav_bar_right_button(title, args = {}) |
Set a right nav bar button.
+ `title` can be a `String` or a `UIImage`.
|
diff --git a/Rakefile b/Rakefile
index 37bb157..34e30b9 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,5 +1,5 @@
$:.unshift("/Library/RubyMotion/lib")
-require 'motion/project'
+require 'motion/project/template/ios'
require 'bundler/gem_tasks'
Bundler.setup
Bundler.require
diff --git a/lib/ProMotion/screens/_screen_module.rb b/lib/ProMotion/screens/_screen_module.rb
index 9eadea6..716a4d9 100644
--- a/lib/ProMotion/screens/_screen_module.rb
+++ b/lib/ProMotion/screens/_screen_module.rb
@@ -78,8 +78,10 @@ module ProMotion
args[:target] ||= self
args[:action] ||= nil
- if args[:system_icon]
- button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_icon], target: args[:target], action: args[:action])
+ button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_icon], target: args[:target], action: args[:action]) if args[:system_icon]
+
+ if args[:title].is_a?(UIImage)
+ button = UIBarButtonItem.alloc.initWithImage(args[:title], style: args[:style], target: args[:target], action: args[:action])
else
button = UIBarButtonItem.alloc.initWithTitle(args[:title], style: args[:style], target: args[:target], action: args[:action])
end
diff --git a/resources/list.png b/resources/list.png
new file mode 100755
index 0000000..263cffd
Binary files /dev/null and b/resources/list.png differ
diff --git a/spec/helpers/home_screen.rb b/spec/helpers/home_screen.rb
index dbde8b4..4ba59f2 100644
--- a/spec/helpers/home_screen.rb
+++ b/spec/helpers/home_screen.rb
@@ -4,10 +4,10 @@ class HomeScreen < ProMotion::Screen
def on_load
set_nav_bar_right_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
- set_nav_bar_left_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
+ set_nav_bar_left_button UIImage.imageNamed("list.png"), action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
end
def on_return(args={})
end
-end
\ No newline at end of file
+end
diff --git a/spec/screen_helpers_spec.rb b/spec/screen_helpers_spec.rb
index 56557f5..ae6c14f 100644
--- a/spec/screen_helpers_spec.rb
+++ b/spec/screen_helpers_spec.rb
@@ -35,25 +35,39 @@ describe "screen helpers" do
@screen.add_to @subview, sub_subview, { backgroundColor: UIColor.redColor }
@subview.subviews.last.backgroundColor.should == UIColor.redColor
end
-
+
end
describe "nav bar buttons" do
-
+
before do
@screen = HomeScreen.new(nav_bar: true)
end
-
+
it "should add a left nav bar button" do
@screen.set_nav_bar_left_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
@screen.navigationItem.leftBarButtonItem.class.should == UIBarButtonItem
end
-
+
it "should add a right nav bar button" do
@screen.set_nav_bar_right_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
@screen.navigationItem.rightBarButtonItem.class.should == UIBarButtonItem
end
-
+
+ it "should add an image right nav bar button" do
+ image = UIImage.imageNamed("list.png")
+ @screen.set_nav_bar_right_button image, action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
+ @screen.navigationItem.rightBarButtonItem.image.class.should == UIImage
+ @screen.navigationItem.rightBarButtonItem.image.should == image
+ end
+
+ it "should add an image left nav bar button" do
+ image = UIImage.imageNamed("list.png")
+ @screen.set_nav_bar_left_button image, action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
+ @screen.navigationItem.leftBarButtonItem.image.class.should == UIImage
+ @screen.navigationItem.leftBarButtonItem.image.should == image
+ end
+
end
describe "screen navigation" do