转盘

作者: 赤焰军少帅林殊 | 来源:发表于2019-06-26 14:04 被阅读0次
    - (void)drawRect:(CGRect)rect
    {
        
        float width =rect.size.width;
        float degrees = (1/(float)8) * 360.f;
        float radius = 2 * width / 5.f + width / 10.f;
        for(int i=0; i<8;i++){
            
            UILabel *label = [[UILabel alloc] init];
            label.text = @"kiss";
            label.textColor = [UIColor blackColor];
            label.numberOfLines = 0;
            label.lineBreakMode = NSLineBreakByTruncatingTail;
            CGSize size = [label sizeThatFits:CGSizeMake(100, 99999)];
            label.frame = CGRectMake(0, 100, size.width, size.height);
            float labelDegees = i * degrees;
            float centerX = AKSin(labelDegees) * 108*kRating + radius;
            float centerY = radius - AKCos(labelDegees) * 108*kRating ;
            label.textAlignment = NSTextAlignmentCenter;
            label.center = CGPointMake(centerX, centerY);
            [self addSubview:label];
            label.transform = CGAffineTransformRotate(label.transform, kDegreesToRadians(labelDegees));
            
            
            UIImageView* imageview=[[UIImageView alloc]init];
            imageview.image=[UIImage imageNamed:@"Kiss2"];
            imageview.frame = CGRectMake(0, 100, 30, 30);
            float imagecenterX = AKSin(labelDegees) * 88*kRating + radius;
            float imagecenterY = radius - AKCos(labelDegees) * 88*kRating;
            imageview.center = CGPointMake(imagecenterX,imagecenterY);
            [self addSubview:imageview];
            imageview.transform = CGAffineTransformRotate(label.transform, kDegreesToRadians(labelDegees));
            
            
            
            
        }
        
    }
    
    
    

    相关文章

      网友评论

          本文标题:转盘

          本文链接:https://www.haomeiwen.com/subject/valccctx.html