Class: Tgios::PhotoScrollView

Inherits:
UIScrollView
  • Object
show all
Defined in:
lib/tgios/photo_scroll_view.rb

Constant Summary collapse

MAX_SCALE =
4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#imageObject

Returns the value of attribute image.



3
4
5
# File 'lib/tgios/photo_scroll_view.rb', line 3

def image
  @image
end

Instance Method Details

#deallocObject



71
72
73
74
# File 'lib/tgios/photo_scroll_view.rb', line 71

def dealloc
  ap "dealloc #{self.class.name}"
  super
end

#initObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/tgios/photo_scroll_view.rb', line 6

def init
  if super
    self.showsVerticalScrollIndicator = false
    self.showsHorizontalScrollIndicator = false
    self.bouncesZoom = true
    self.decelerationRate = UIScrollViewDecelerationRateFast
    self.delegate = self
    self.backgroundColor = :clear.uicolor
  end
  self
end

#initWithFrame(frame, image: image) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/tgios/photo_scroll_view.rb', line 18

def initWithFrame(frame, image: image)
  init
  self.frame = frame
  self.image = image

  self
end

#layoutSubviewsObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/tgios/photo_scroll_view.rb', line 51

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



67
68
69
# File 'lib/tgios/photo_scroll_view.rb', line 67

def viewForZoomingInScrollView(scrollView)
  @image_view
end