Open ahmedshabbirawan opened 8 years ago
@ahmedshabbirawan can you provide some more details or some sample code?
This is the major code
static CFTimeInterval const kDuration = 2.0; static CFTimeInterval const kInitialTimeOffset = 2.0;
@interface ViewController (){ PathBuilderView *ahmedView; }
@property (nonatomic, readonly) PathBuilderView *pathBuilderView;
@end
@implementation ViewController
(void)viewDidLoad { [super viewDidLoad];
ahmedView = [[PathBuilderView alloc] initWithFrame:CGRectMake(0, 60, self.view.frame.size.width, 250)]; ahmedView.backgroundColor = [UIColor clearColor]; ahmedView.pointsShapeView.alpha = 1.0; [self.view addSubview:ahmedView]; // self.view.backgroundColor = [UIColor whiteColor];
ahmedView.pathShapeView.shapeLayer.strokeColor = [UIColor blackColor].CGColor; ahmedView.prospectivePathShapeView.shapeLayer.strokeColor = [UIColor grayColor].CGColor; ahmedView.pointsShapeView.shapeLayer.strokeColor = [UIColor blackColor].CGColor;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:NSStringFromSelector(@selector(strokeEnd))]; animation.fromValue = @0.0; animation.toValue = @1.0; animation.removedOnCompletion = NO; animation.duration = kDuration; [ahmedView.pathShapeView.shapeLayer addAnimation:animation forKey:NSStringFromSelector(@selector(strokeEnd))];
ahmedView.pathShapeView.shapeLayer.speed = 0; ahmedView.pathShapeView.shapeLayer.timeOffset = 0.0;
[CATransaction flush];
ahmedView.pathShapeView.shapeLayer.timeOffset = kInitialTimeOffset;
UISwitch *showDotsSwitch = [[UISwitch alloc] init]; showDotsSwitch.on = YES; [showDotsSwitch addTarget:self action:@selector(showDotsSwitchValueChanged:) forControlEvents:UIControlEventValueChanged]; showDotsSwitch.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:showDotsSwitch];
UILabel *showDotsLabel = [[UILabel alloc] init]; showDotsLabel.text = NSLocalizedString(@"Show dots", nil); showDotsLabel.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:showDotsLabel];
UISlider strokeEndSlider = [[UISlider alloc] init]; strokeEndSlider.minimumValue = 0.0; strokeEndSlider.maximumValue = kDuration; strokeEndSlider.value = kInitialTimeOffset; strokeEndSlider.continuous = YES; [strokeEndSlider addTarget:self action:@selector(strokeEndSliderValueChanged:) forControlEvents:UIControlEventValueChanged]; strokeEndSlider.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:strokeEndSlider]; // UIButton drawPathButton = [UIButton buttonWithType:UIButtonTypeSystem]; [drawPathButton setTitle:NSLocalizedString(@"Draw Path", nil) forState:UIControlStateNormal]; [drawPathButton addTarget:self action:@selector(drawPathButtonTapped) forControlEvents:UIControlEventTouchUpInside]; drawPathButton.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:drawPathButton];
NSDictionary *views = NSDictionaryOfVariableBindings(showDotsLabel, showDotsSwitch, drawPathButton); [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[showDotsLabel]-[showDotsSwitch]->=20-[drawPathButton]-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:views]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[showDotsSwitch]-|" options:0 metrics:nil views:views]];
id topLayoutGuide = self.topLayoutGuide; views = NSDictionaryOfVariableBindings(strokeEndSlider, topLayoutGuide); [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[strokeEndSlider]-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:views]]; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topLayoutGuide][strokeEndSlider]" options:0 metrics:nil views:views]]; }
Thanks @macdrevx . its done.
Thanks. I tried it out but I wasn't able to reproduce the crash. Could you post a crash log or a stack trace?
I was create outlet and assign the class which was wrong . Now i have create instance and initialize with frame following are the code
@interface ViewController (){ PathBuilderView *ahmedView; } @end
@implementation ViewController
Hmm, I'm not sure I can help without more detail about what exactly is crashing. Let me know if you're able to get a stack trace.
when i use for Custom UIView it have crush.