mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-05-26 15:43:57 +08:00
retina mode support
This commit is contained in:
@@ -57,13 +57,18 @@ task :simulator => ['build:simulator'] do
|
||||
end
|
||||
|
||||
# Prepare the device family.
|
||||
family_int =
|
||||
family_int, retina =
|
||||
if family = ENV['device_family']
|
||||
App.config.device_family_int(family.downcase.intern)
|
||||
str = family.downcase
|
||||
retina = str.sub!(/\:retina$/, '') ? true : false
|
||||
[App.config.device_family_int(str.intern), retina]
|
||||
else
|
||||
App.config.device_family_ints[0]
|
||||
[App.config.device_family_ints[0], false]
|
||||
end
|
||||
|
||||
# Configure the SimulateDevice variable (the only way to specify if we want to run in retina mode or not).
|
||||
sh "/usr/bin/defaults write com.apple.iphonesimulator \"SimulateDevice\" \"'#{App.config.device_family_string(family_int, retina)}'\""
|
||||
|
||||
# Launch the simulator.
|
||||
xcode = App.config.xcode_dir
|
||||
env = xcode.match(/^\/Applications/) ? "DYLD_FRAMEWORK_PATH=\"#{xcode}/../Frameworks\":\"#{xcode}/../OtherFrameworks\"" : ''
|
||||
|
||||
@@ -381,6 +381,16 @@ EOS
|
||||
end
|
||||
end
|
||||
|
||||
def device_family_string(family, retina)
|
||||
device = case family
|
||||
when :iphone, 1
|
||||
"iPhone"
|
||||
when :ipad, 2
|
||||
"iPad"
|
||||
end
|
||||
retina ? device + " (Retina)" : device
|
||||
end
|
||||
|
||||
def device_family_ints
|
||||
ary = @device_family.is_a?(Array) ? @device_family : [@device_family]
|
||||
ary.map { |family| device_family_int(family) }
|
||||
|
||||
Reference in New Issue
Block a user