We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
贴上修复方式,供你参考,如果说有更好的方式,渴望有你的不同见解
// update UI if (_contentType == YUSegmentedControlContentTypeText) { for (Item *item in _items) { NSInteger index = [_items indexOfObject:item]; UILabel *deselectedLabel = (UILabel *)(item.view); deselectedLabel.attributedText = [[NSAttributedString alloc] initWithString:_contents[index] attributes:_attributesNormal]; } UILabel *selectedLabel = (UILabel *)(_items[newIndex].view); selectedLabel.attributedText = [[NSAttributedString alloc] initWithString:_contents[newIndex] attributes:_attributesSelected];
// UILabel *deselectedLabel = (UILabel *)(_items[oldIndex].view); // deselectedLabel.attributedText = [[NSAttributedString alloc] initWithString:_contents[oldIndex] attributes:_attributesNormal]; } else { if (_selectedImages) { UIImageView *selectedImageView = (UIImageView *)(_items[newIndex].view); selectedImageView.image = _selectedImages[newIndex]; UIImageView *deselectedImageView = (UIImageView *)(_items[oldIndex].view); deselectedImageView.image = _contents[oldIndex]; } } // animation [self moveIndicatorFromIndex:oldIndex toIndex:newIndex]; }
// CABasicAnimation *animation; // CGPoint position = _indicator.position; // CGFloat position_x = position.x + CGRectGetWidth(_indicator.bounds) * (toIndex - fromIndex); // position.x = position_x; // // if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) { // animation = [CASpringAnimation animationWithKeyPath:@"position.x"]; // } else { // animation = [CABasicAnimation animationWithKeyPath:@"position.x"]; // } // animation.toValue = [NSValue valueWithCGPoint:position]; // animation.duration = 0.25;
// indicator animate CGRect frame = _indicator.frame; frame.origin.x = CGRectGetWidth(_indicator.bounds) * toIndex ; NSLog(@"%f",frame.origin.x); [UIView animateWithDuration:kAnimationDuration delay:0.0 usingSpringWithDamping:0.66 initialSpringVelocity:3.0 options:UIViewAnimationOptionCurveLinear animations:^{ _indicator.frame = frame; } completion:^(BOOL finished) { if (finished) { _selectedSegmentIndex = toIndex; [self sendActionsForControlEvents:UIControlEventValueChanged]; } }];
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
贴上修复方式,供你参考,如果说有更好的方式,渴望有你的不同见解
- (void)segmentDidSelectAtIndex:(NSUInteger)newIndex didDeselectAtIndex:(NSUInteger)oldIndex {
// UILabel *deselectedLabel = (UILabel *)(_items[oldIndex].view);
// deselectedLabel.attributedText = [[NSAttributedString alloc] initWithString:_contents[oldIndex] attributes:_attributesNormal];
}
else {
if (_selectedImages) {
UIImageView *selectedImageView = (UIImageView *)(_items[newIndex].view);
selectedImageView.image = _selectedImages[newIndex];
UIImageView *deselectedImageView = (UIImageView *)(_items[oldIndex].view);
deselectedImageView.image = _contents[oldIndex];
}
}
// animation
[self moveIndicatorFromIndex:oldIndex toIndex:newIndex];
}
// CABasicAnimation *animation;
// CGPoint position = _indicator.position;
// CGFloat position_x = position.x + CGRectGetWidth(_indicator.bounds) * (toIndex - fromIndex);
// position.x = position_x;
//
// if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
// animation = [CASpringAnimation animationWithKeyPath:@"position.x"];
// } else {
// animation = [CABasicAnimation animationWithKeyPath:@"position.x"];
// }
// animation.toValue = [NSValue valueWithCGPoint:position];
// animation.duration = 0.25;
}
The text was updated successfully, but these errors were encountered: