LoginSignup
12
12

More than 5 years have passed since last update.

RubyMotionでiOS Simulatorを任意の拡大/縮小率にセットする

Last updated at Posted at 2014-09-17

RubyMotion Kaigiに行くので、簡単にコマンドとして作ってみました。

↓自分のエントリーですが、参考までに。
iOS Simulatorを任意の拡大/縮小率で表示する

インストール

~/Library/RubyMotion/command/scale.rbとしてのコードを保存します。

~/Library/RubyMotion/command/scale.rb
module Motion; class Command
  class Scale < Command
    self.summary = 'Set Simulator Scale'
    self.description = 'Set iOS Simulator Window Scale. Set value (0.3 = 0.3x).'
    self.arguments = '[zoom_scale]'

    def initialize(argv)
      @zoom_scale = argv.shift_argument
      super
    end

    def validate!
      super
      help! "Specify a window scale of iOS Simulatorter." unless @zoom_scale
    end

    def run
      line = "defaults write com.apple.iphonesimulator SimulatorWindowLastScale "
      line << "#{@zoom_scale}"
      system(line)
    end
  end
end; end

使い方

プロジェクトディレクトリーで

motion scale 0.4
rake device_name="iPhone 6 Plus"

とすれば0.4倍にシミュレータのズームサイズを設定してiPhone6 Plusで実行できます。

ごにょごにょ

RubyMotionのコマンドとして追加するよりはrakeコマンドとして「rake device_name="iPhone 6 Plus" scale=0.4」のように
作った方が適切かもしれませんが、ちょっと調べきれなかったので。

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12