Class: Tgios::PhotoScrollView
- Inherits:
-
UIScrollView
- Object
- UIScrollView
- Tgios::PhotoScrollView
- Defined in:
- lib/tgios/photo_scroll_view.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#image ⇒ Object
Returns the value of attribute image.
-
#max_scale ⇒ Object
Returns the value of attribute max_scale.
-
#min_content_type ⇒ Object
Returns the value of attribute min_content_type.
Instance Method Summary collapse
- #dealloc ⇒ Object
- #get_scale(type, image) ⇒ Object
- #init ⇒ Object
- #initWithFrame(frame, image: image) ⇒ Object
- #layoutSubviews ⇒ Object
- #viewForZoomingInScrollView(scrollView) ⇒ Object
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
3 4 5 |
# File 'lib/tgios/photo_scroll_view.rb', line 3 def content_type @content_type end |
#image ⇒ Object
Returns the value of attribute image.
3 4 5 |
# File 'lib/tgios/photo_scroll_view.rb', line 3 def image @image end |
#max_scale ⇒ Object
Returns the value of attribute max_scale.
3 4 5 |
# File 'lib/tgios/photo_scroll_view.rb', line 3 def max_scale @max_scale end |
#min_content_type ⇒ Object
Returns the value of attribute min_content_type.
3 4 5 |
# File 'lib/tgios/photo_scroll_view.rb', line 3 def min_content_type @min_content_type end |
Instance Method Details
#dealloc ⇒ Object
92 93 94 95 |
# File 'lib/tgios/photo_scroll_view.rb', line 92 def dealloc ap "dealloc #{self.class.name}" super end |
#get_scale(type, image) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/tgios/photo_scroll_view.rb', line 71 def get_scale(type, image) horizontal_scale = frame.size.width / image.size.width vertical_scale = frame.size.height / image.size.height case type when :horizontal horizontal_scale when :vertical vertical_scale when :fit [horizontal_scale, vertical_scale].min when :fill [horizontal_scale, vertical_scale].max else horizontal_scale end end |
#init ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tgios/photo_scroll_view.rb', line 5 def init if super self.showsVerticalScrollIndicator = false self.showsHorizontalScrollIndicator = false self.bouncesZoom = true self.decelerationRate = UIScrollViewDecelerationRateFast self.delegate = self self.backgroundColor = :clear.uicolor @max_scale = 4.0 @content_type = @min_content_type = :horizontal # :horizontal, :vertical, :fit, :fill @image_view = PlasticCup::Base.style(UIImageView.new, contentMode: UIViewContentModeScaleAspectFit) self.addSubview(@image_view) end self end |
#initWithFrame(frame, image: image) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/tgios/photo_scroll_view.rb', line 22 def initWithFrame(frame, image: image) init self.frame = frame self.image = image self end |
#layoutSubviews ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/tgios/photo_scroll_view.rb', line 55 def layoutSubviews super unless @image_view.nil? bsize = self.bounds.size center_frame = @image_view.frame center_frame.origin.x = center_frame.size.width < bsize.width ? (bsize.width - center_frame.size.width) / 2.0 : 0 center_frame.origin.y = center_frame.size.height < bsize.height ? (bsize.height - center_frame.size.height) / 2.0 : 0 @image_view.frame = center_frame @image_view.contentScaleFactor = 1.0 end end |
#viewForZoomingInScrollView(scrollView) ⇒ Object
88 89 90 |
# File 'lib/tgios/photo_scroll_view.rb', line 88 def viewForZoomingInScrollView(scrollView) @image_view end |