Customize the Airplay button's appearance

后端 未结 5 804
小鲜肉
小鲜肉 2020-12-23 00:22

I use a standard gradient overlay (done in photoshop) to make buttons look nicer in my app. I added an Airplay button, but the aesthetics are not matching.

5条回答
  •  庸人自扰
    2020-12-23 00:50

    I created a custom method which works perfectly...

    -(void)airplayIcon:(CGRect)rect {
        UIView *aiplayView = [[UIView alloc] initWithFrame:self.bounds];
        aiplayView.clipsToBounds = true;
        aiplayView.backgroundColor = [UIColor clearColor];
        [self addSubview:aiplayView];
    
        MPVolumeView *airplayVolume = [[MPVolumeView alloc] initWithFrame:aiplayView.bounds];
        airplayVolume.showsVolumeSlider = false;
        [aiplayView addSubview:airplayVolume];
    
        for (UIButton *button in airplayVolume.subviews) {
            [button setFrame:self.bounds];
            if ([button isKindOfClass:[UIButton class]]) {
                [button setImage:[UIImage imageNamed:@"normal.png"] forState:UIControlStateNormal];
                [button setImage:[UIImage imageNamed:@"selected.png"] forState:UIControlStateSelected];
                [button sizeToFit];
    
            }
    
        }
    
    }
    

提交回复
热议问题