转盘

2019-06-26  本文已影响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));
        
        
        
        
    }
    
}


上一篇下一篇

猜你喜欢

热点阅读