Skip to content

Instantly share code, notes, and snippets.

@duxins
Last active September 18, 2015 01:23
Show Gist options
  • Select an option

  • Save duxins/5cb7b14e3912cc8dac90 to your computer and use it in GitHub Desktop.

Select an option

Save duxins/5cb7b14e3912cc8dac90 to your computer and use it in GitHub Desktop.
RubyMotion 截屏
# http://paulsturgess.co.uk/blog/2015/02/05/tweeting-a-screenshot-in-rubymotion-with-uiactivityviewcontroller/
def screenshot
window = UIApplication.sharedApplication.keyWindow
UIGraphicsBeginImageContextWithOptions(
window.bounds.size,
false,
UIScreen.mainScreen.scale
)
window.drawViewHierarchyInRect(
window.bounds,
afterScreenUpdates:true
)
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
image
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment