1.Firstly, Copy the following DFM string to StyleDesigner
object
TSwitchObject
StyleName = 'IOSSwitchStyle'
Align = Center
Kind = FadingTracks
Size.Width = 78.000000000000000000
Size.Height = 35.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
TrackingThumbScale = 1.179999947547913000
Fill.Color = claWhite
FillOn.Color = xFF4CD964
FillOn.Kind = Solid
Stroke.Color = xA3C6C6C8
Thumb.Color = claWhite
ThumbStroke.Color = xA3C6C6C8
ThumbStroke.Cap = Round
ThumbStroke.Dash = Custom
ThumbStroke.Join = Round
Shape = Oval
FixedWidth = 55
FixedHeight = 30
end
Then Set these properties:
StyleName = 'IOSSwitchStyle' name of the style,if set to switchstyle,all the TSwich in application will apply this style by default
Kind = FadingTracks kind, one is fading and one is cliping
Fading:
Background color change when thumb slide to center. Default effect of IOS:
Clipping:
Background is clipped by the thumb:
TrackingThumbScale = 1.179999947547913000 X scale when clicked.
Fill.Color = claWhite Background color when OFF.
FillOn.Color = xFF4CD964 Background color when ON.
FillOn.Kind = Solid Fill kind when ON.
Stroke.Color = xA3C6C6C8 Border color.
Thumb.Color = claWhite Thumb color.
ThumbStroke.Color = xA3C6C6C8 Thumb border color.
Shape = Oval shape
FixedWidth = 55
FixedHeight = 30
Then we can set StyleLookUp in Object Inspector:
The above style is vector style, if you want to use bitmapstyle, use TBitmapSwitchObject instead.(Look at the stock style).
This is our style:
But there is a bug in TBrush. TBrushKind.bkGrab is missing. For the lock icon in the demo, we can only use Bitmap, can't use vector.(e.g. TPath). It will blur on different resolutions.(In the following image, the top image is vector(TLayout contains TPath and TCircle ) , flowing is bitmap).
Please vote here to let emb fix the bug:
Demo Download: https://drive.google.com/file/d/0BwdfodaqQm4pOVFWS1NMdTNacFk/view?usp=sharing
没有评论:
发表评论