저는 Core Animation을 처음 사용하고 RubyMotion을 처음 사용합니다 (1 월부터 Xcode에서 Obj-C로 작업 해왔음). AppLabel이 필요합니다 (AppAppearance.rb라는 파일에 png가 지정되어 있지만 모든 애니메이션은이 파일에 있습니다). 지금은 animateWithDuration을 사용하고 있지만 레이블이로드 될 때 왼쪽으로 약간 바운스해야합니다. 이것에 대한 가능한 모든 도움은 매우 감사 할 것입니다, 나는 하루 종일 서클에서 돌아 다녔습니다. 나는이 코드를 사용하려고합니다 : bounce an image in to view과 내가 CAKeyFrameAnimation에서 찾을 수있는 것이지만 Obj-C를 Ruby로 변환하려고합니다. 감사!RubyMotion으로 이미지를 바운스하기 위해 CAKeyFrameAnimation (또는 다른 것)을 사용합니다.
class AppLabel < UILabel
#-------------------------
DefaultHeight = 45
DefaultWidth = 170
def initWithFrame(frame)
#-------------------------
if (super(frame))
@showing = false
@hiding = false
self.size.width = 170 if self.size.width == 0
self.size.height = 46 if self.size.height == 0
self.backgroundColor = AppAppearance.appLabelBackgroundColor
self.font = AppAppearance.fontWithSize(14)
self.textColor = AppAppearance.appLabelTextColor
self.numberOfLines = 2
end
self
end
#
# method. drawTextInRect
#
def drawTextInRect(rect)
#-------------------------
rect.origin.x += 10
rect.origin.y += 2
rect.size.width -= 30
super(rect)
end
#
# method. show
#
def show
#-------
if ((self.hidden? || self.alpha < 1) && [email protected])
if self.hidden?
self.alpha = 0.0
self.hidden = false
end
@showing = true
UIView.animateWithDuration(
1.0,
animations: lambda do
self.alpha = 1.0
end,
completion: lambda do | finished |
@showing = false
end
)
end
end
#
# method. hide
#
def hide
#-------
unless (self.hidden? || self.alpha == 0 || @hiding)
log('hiding')
@hiding = true
UIView.animateWithDuration(
1.0,
animations: lambda do
self.alpha = 0.0
end,
completion: lambda do | finished |
self.hidden = true
@hiding = false
end
)
end
end
end