mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-05-26 23:30:38 +08:00
Merge pull request #527 from clearsightstudio/bugfix/524
Fixes issue 524.
This commit is contained in:
15
app/test_screens/uiimage_title_screen.rb
Normal file
15
app/test_screens/uiimage_title_screen.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class UIImageTitleScreen < PM::Screen
|
||||
attr_accessor :button_was_triggered
|
||||
|
||||
title_image UIImage.imageNamed('test.png')
|
||||
|
||||
def will_appear
|
||||
self.button_was_triggered = false
|
||||
add UILabel.alloc.initWithFrame([[ 10, 10 ], [ 300, 40 ]]),
|
||||
text: "Label Here"
|
||||
end
|
||||
|
||||
def triggered_button
|
||||
self.button_was_triggered = true
|
||||
end
|
||||
end
|
||||
@@ -27,7 +27,7 @@ module ProMotion
|
||||
case self.class.title_type
|
||||
when :text then self.title = self.class.title
|
||||
when :view then self.navigationItem.titleView = self.class.title
|
||||
when :image then self.navigationItem.titleView = UIImageView.alloc.initWithImage(UIImage.imageNamed(self.class.title))
|
||||
when :image then self.navigationItem.titleView = UIImageView.alloc.initWithImage(self.class.title)
|
||||
else
|
||||
PM.logger.warn("title expects string, UIView, or UIImage, but #{self.class.title.class.to_s} given.")
|
||||
end
|
||||
@@ -178,7 +178,7 @@ module ProMotion
|
||||
end
|
||||
|
||||
def title_image(t)
|
||||
@title = t
|
||||
@title = t.is_a?(UIImage) ? t : UIImage.imageNamed(t)
|
||||
@title_type = :image
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
describe "ProMotion::Screen UIImage title" do
|
||||
describe "ProMotion::Screen UIImage string title" do
|
||||
def controller
|
||||
@controller = ImageTitleScreen.new(nav_bar: true)
|
||||
end
|
||||
|
||||
it "should allow an image title" do
|
||||
it "should allow an image title as a String" do
|
||||
controller.navigationItem.titleView.should.be.kind_of UIImageView
|
||||
end
|
||||
end
|
||||
|
||||
describe "ProMotion::Screen UIImage title" do
|
||||
def controller
|
||||
@controller = UIImageTitleScreen.new(nav_bar: true)
|
||||
end
|
||||
|
||||
it "should allow an image title as a UIImage" do
|
||||
controller.navigationItem.titleView.should.be.kind_of UIImageView
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user