orientation
import "github.com/tangoui/tango/sys/orientation"本页由
site/tools/apigen从源码注释生成(按 darwin 构建标签选文件),请勿手改。
Package orientation reads and locks the interface orientation.
o, _ := orientation.Get(a) // orientation.Portrait, ...
orientation.Lock(a, orientation.Landscape)
orientation.Unlock(a)
orientation.OnChange(a, func(o orientation.Orientation) { ... })
Locking only chooses among the orientations the app declares (UISupportedInterfaceOrientations on iOS; Android allows all). On iPad, apps that support multitasking (split view) cannot lock; iOS ignores the request there.
Functions return ErrUnsupported on desktop and tango.ErrNotRunning after the app quit.
常量
const (
Unknown = platform.OrientationUnknown
Portrait = platform.OrientationPortrait
PortraitUpsideDown = platform.OrientationPortraitUpsideDown
LandscapeLeft = platform.OrientationLandscapeLeft
LandscapeRight = platform.OrientationLandscapeRight
)const (
MaskPortrait = platform.MaskPortrait
MaskPortraitUpsideDown = platform.MaskPortraitUpsideDown
MaskLandscapeLeft = platform.MaskLandscapeLeft
MaskLandscapeRight = platform.MaskLandscapeRight
Landscape = platform.MaskLandscape // either landscape
PortraitOnly = platform.MaskPortrait
All = platform.MaskAll
)变量
var ErrUnsupported = platform.ErrUnsupported函数
func IsLandscape
func IsLandscape(o Orientation) boolIsLandscape reports whether o is a landscape orientation.
func Lock
func Lock(a *tango.App, m Mask) errorLock restricts the interface to m, rotating if needed.
func OnChange
func OnChange(a *tango.App, fn func(Orientation))OnChange calls fn on the main thread with the new orientation whenever it changes. It does nothing on desktop.
func String
func String(o Orientation) stringString names o: "portrait", "portraitUpsideDown", "landscapeLeft", "landscapeRight" or "unknown".
func Unlock
func Unlock(a *tango.App) errorUnlock lifts a Lock.
类型
Mask
type Mask = platform.OrientationMaskMask is a set of orientations for Lock.
Orientation
type Orientation = platform.OrientationOrientation is named by where the device's top edge points: LandscapeLeft is the device turned 90° counter-clockwise from portrait.
func Get
func Get(a *tango.App) (Orientation, error)Get returns the current interface orientation.