123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- //
- // XYRotarytableWinningView.m
- // Timi
- //
- // Created by 翟玉磊 on 2021/4/19.
- //
- #import "XYRotarytableWinningView.h"
- @interface XYRotarytableWinningView ()
- @property (nonatomic, strong) UIView *infoView;
- @property (nonatomic, strong) UIImageView *bgImageView;
- @property (nonatomic, strong) UIImageView *textBgImageView;
- @property (nonatomic, strong) UILabel *textLabel;
- @end
- @implementation XYRotarytableWinningView
- #pragma mark — Public
- - (void)clear {
- for (UIView *view in self.subviews) {
- [view removeFromSuperview];
- }
- }
- - (void)startAnimationWithText:(NSString *)text {
- self.textLabel.text = text;
- [self startAnimation];
- }
- - (void)startAnimation {
- [UIView animateWithDuration:.3 animations:^{
- self.infoView.frame = CGRectMake(self.infoView.f_x, 0, self.infoView.f_width, self.infoView.f_width);
- } completion:^(BOOL finished) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self endAnimation];
- });
- }];
- }
- - (void)endAnimation {
- [UIView animateWithDuration:.3 animations:^{
- self.infoView.frame = CGRectMake(self.infoView.f_x, self.infoView.f_width, self.infoView.f_width, self.infoView.f_width);
- } completion:^(BOOL finished) {
- [self clear];
- }];
- }
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self setupUI];
- }
- return self;
- }
- - (void)setupUI {
- self.backgroundColor = Color_Clear;
-
- [self addSubview:self.infoView];
- [self.infoView addSubview:self.bgImageView];
- [self.infoView addSubview:self.textBgImageView];
- [self.infoView addSubview:self.textLabel];
- }
- #pragma mark — Getter
- - (UIView *)infoView {
- if (!_infoView) {
- CGFloat width = self.f_width - 50.0f - 50.0f;
- CGFloat height = 44.0f;
- _infoView = [[UIView alloc] initWithFrame:CGRectMake(50.0f, -height, width, height)];
- _infoView.backgroundColor = Color_Clear;
- }
- return _infoView;
- }
- - (UIImageView *)bgImageView {
- if (!_bgImageView) {
- _bgImageView = [[UIImageView alloc] initWithFrame:self.infoView.bounds];
- _bgImageView.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(_bgImageView.f_width, _bgImageView.f_heigh) direction:GradientChangeDirectionVertical startColor:ColorFromHexString(@"#FA5DDB") endColor:ColorFromHexString(@"#7C7EFE")];
- [_bgImageView addViewBorder:Color_Clear redian:5];
- }
- return _bgImageView;
- }
- - (UIImageView *)textBgImageView {
- if (!_textBgImageView) {
- CGFloat width = self.bgImageView.f_width - 7.0f - 7.0f;
- CGFloat height = self.bgImageView.f_heigh - 7.0f - 7.0f;
- _textBgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(7.0f, 7.0f, width, height)];
- _textBgImageView.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(width, height) direction:GradientChangeDirectionVertical startColor:ColorFromHexString(@"#AA24F8") endColor:ColorFromHexString(@"#6460FF")];
- [_textBgImageView addViewBorder:Color_Clear redian:5];
- }
- return _textBgImageView;
- }
- - (UILabel *)textLabel {
- if (!_textLabel) {
- _textLabel = [UILabel createLabelTextColor:Color_White fount:Font(13)];
- _textLabel.textAlignment = NSTextAlignmentCenter;
- _textLabel.frame = CGRectMake(14.0f, 14.0f, self.infoView.f_width - 14.0f - 14.0f, 16.0f);
- }
- return _textLabel;
- }
- @end
|