mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-06 20:54:04 +00:00
Updated example
This commit is contained in:
parent
b0ddddac01
commit
4038d3a7c3
1
Example/Tests/Switch_States.json
Normal file
1
Example/Tests/Switch_States.json
Normal file
File diff suppressed because one or more lines are too long
@ -66,6 +66,7 @@
|
||||
622F770B1F2BE63100269858 /* Z.json in Resources */ = {isa = PBXBuildFile; fileRef = 622F76ED1F2BE63100269858 /* Z.json */; };
|
||||
629EC57F1F54BFF1005B2C59 /* LAControlsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 629EC57E1F54BFF1005B2C59 /* LAControlsViewController.m */; };
|
||||
629EC5811F54C00B005B2C59 /* Switch.json in Resources */ = {isa = PBXBuildFile; fileRef = 629EC5801F54C00B005B2C59 /* Switch.json */; };
|
||||
629EC5891F54C925005B2C59 /* Switch_States.json in Resources */ = {isa = PBXBuildFile; fileRef = 629EC5881F54C925005B2C59 /* Switch_States.json */; };
|
||||
62B2546A1E3A8D310035A842 /* LottieRootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254631E3A8D310035A842 /* LottieRootViewController.m */; };
|
||||
62B2546B1E3A8D310035A842 /* AnimationExplorerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254651E3A8D310035A842 /* AnimationExplorerViewController.m */; };
|
||||
62B2546C1E3A8D310035A842 /* AnimationTransitionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 62B254671E3A8D310035A842 /* AnimationTransitionViewController.m */; };
|
||||
@ -171,6 +172,7 @@
|
||||
629EC57D1F54BFF1005B2C59 /* LAControlsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LAControlsViewController.h; sourceTree = "<group>"; };
|
||||
629EC57E1F54BFF1005B2C59 /* LAControlsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LAControlsViewController.m; sourceTree = "<group>"; };
|
||||
629EC5801F54C00B005B2C59 /* Switch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Switch.json; sourceTree = "<group>"; };
|
||||
629EC5881F54C925005B2C59 /* Switch_States.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Switch_States.json; sourceTree = "<group>"; };
|
||||
62B254621E3A8D310035A842 /* LottieRootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LottieRootViewController.h; sourceTree = "<group>"; };
|
||||
62B254631E3A8D310035A842 /* LottieRootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LottieRootViewController.m; sourceTree = "<group>"; };
|
||||
62B254641E3A8D310035A842 /* AnimationExplorerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationExplorerViewController.h; sourceTree = "<group>"; };
|
||||
@ -343,6 +345,7 @@
|
||||
6003F5B6195388D20070C39A /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
629EC5881F54C925005B2C59 /* Switch_States.json */,
|
||||
622F76CF1F2BE63100269858 /* TypeFace */,
|
||||
622F76B51F2BE58100269858 /* 9squares-AlBoardman.json */,
|
||||
629EC5801F54C00B005B2C59 /* Switch.json */,
|
||||
@ -614,6 +617,7 @@
|
||||
622F77071F2BE63100269858 /* V.json in Resources */,
|
||||
622F77061F2BE63100269858 /* U.json in Resources */,
|
||||
622F76CE1F2BE58100269858 /* Watermelon.json in Resources */,
|
||||
629EC5891F54C925005B2C59 /* Switch_States.json in Resources */,
|
||||
622F77041F2BE63100269858 /* S.json in Resources */,
|
||||
622F770A1F2BE63100269858 /* Y.json in Resources */,
|
||||
6003F598195388D20070C39A /* InfoPlist.strings in Resources */,
|
||||
|
@ -37,18 +37,44 @@
|
||||
[toggle1 setProgressRangeForOffState:0 toProgress:0.5];
|
||||
|
||||
[toggle1 addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged];
|
||||
toggle1.center = CGPointMake(CGRectGetMidX(self.view.bounds), 90);
|
||||
[self.view addSubview:toggle1];
|
||||
|
||||
/// An animated 'like' or 'heart' button.
|
||||
/// Clicking toggles the Like or Heart state.
|
||||
/// The animation runs from 0-1, progress 0 is off, progress 1 is on
|
||||
LOTAnimatedSwitch *heartIcon = [LOTAnimatedSwitch switchNamed:@"TwitterHeart"];
|
||||
heartIcon.bounds = CGRectMake(0, 0, 200, 200);
|
||||
heartIcon.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMaxY(toggle1.frame) + (heartIcon.bounds.size.height * 0.5));
|
||||
|
||||
[heartIcon addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged];
|
||||
[self.view addSubview:heartIcon];
|
||||
|
||||
/// This is a switch that also has a Disabled state animation.
|
||||
/// When the switch is disabled then the disabled layer is displayed.
|
||||
|
||||
LOTAnimatedSwitch *statefulSwitch = [LOTAnimatedSwitch switchNamed:@"Switch_States"];
|
||||
|
||||
/// Off animation is 0 to 1 progress.
|
||||
/// On animation is 1 to 0 progress.
|
||||
[statefulSwitch setProgressRangeForOnState:1 toProgress:0];
|
||||
[statefulSwitch setProgressRangeForOffState:0 toProgress:1];
|
||||
|
||||
// Specify the layer names for different states
|
||||
[statefulSwitch setLayerName:@"Button" forState:UIControlStateNormal];
|
||||
[statefulSwitch setLayerName:@"Disabled" forState:UIControlStateDisabled];
|
||||
|
||||
// Changes visual appearance by switching animation layer to "Disabled"
|
||||
statefulSwitch.enabled = NO;
|
||||
|
||||
// Changes visual appearance by switching animation layer to "Button"
|
||||
statefulSwitch.enabled = YES;
|
||||
|
||||
[statefulSwitch addTarget:self action:@selector(switchToggled:) forControlEvents:UIControlEventValueChanged];
|
||||
[self.view addSubview:statefulSwitch];
|
||||
|
||||
// Layout
|
||||
toggle1.center = CGPointMake(CGRectGetMidX(self.view.bounds), 90);
|
||||
heartIcon.bounds = CGRectMake(0, 0, 200, 200);
|
||||
heartIcon.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMaxY(toggle1.frame) + (heartIcon.bounds.size.height * 0.5));
|
||||
statefulSwitch.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMaxY(heartIcon.frame) + (statefulSwitch.bounds.size.height * 0.5));
|
||||
}
|
||||
|
||||
- (void)switchToggled:(LOTAnimatedSwitch *)animatedSwitch {
|
||||
|
Loading…
x
Reference in New Issue
Block a user