Total Pageviews

Tuesday, June 3, 2014

នេះជា Type SwitchWidgets របស់ Corona SDK

នេះជា Type SwitchWidgets របស់ Corona SDK
សំរាប់ Switch objects ត្រូវបានបង្កើតឡើងដោយប្រើ widget.newSwitch()
នេះជា Properties របស់វា
Object.isOn
វាជា read only state របស់ ​switch វាអាចជា true for on/selected or false for off/deselected

Methods:
Object:setState()
ប្រើសំរាប់ programmatically បញ្ចូលទៅកាន់ state of a switch។ វាអាចផ្លាស់ប្តូរនៅ state of the switch visually
Syntax: object:setState (options)
សំរាប់ហ្វាំងសិននេះវាមានតែ single argument options គឺជាតារាងដែលទទួលនៅ parameters ដូចនេះ
isOn (តំរូវការ) វាជា Boolean ដែលបញ្ចូលនៅ Switch ទៅជា  true (on) or false (off)
isAnimated(ជំរើស) វាជា Boolean ដែលប្រើបានតែជាមួយនឹង​ switches ជាមួយនឹង style of onOff បើសិនជាដាក់ជា true the switch will visually animate its state change
onComplete(ជំរើស) វាជា listener ដែលជា callback function ដែលត្រូវហៅនៅពេលដែល switch បានផ្លាស់ប្តូរ state

សូមមើលកូដះ
-- Create a default on/off switch
local onOffSwitch = widget.newSwitch
{
    left = 100,
    top = 300,
    initialSwitchState = true
}

local function changeComplete()
    print( "Switch change complete!" )
end

-- Set the on/off switch to off
onOffSwitch:setState( { isOn=false, isAnimated=true, onComplete=changeComplete } )


No comments:

Post a Comment