这里只做记录,具体的逻辑可以去网上查看。
UIButton * changeBtn =[UIButton buttonWithType:UIButtonTypeCustom];
changeBtn.frame=CGRectMake(SCREEN_WIDTH-94,CGRectGetMaxY(self.msgImage.frame)-20,60,20);
changeBtn.layer.cornerRadius=10;
changeBtn.layer.masksToBounds=YES;
[changeBtnaddTarget:self action:@selector(changeBtnClick) forControlEvents:UIControlEventTouchUpInside];
CAGradientLayer* gradientLayer = [CAGradientLayer layer];
gradientLayer.frame=CGRectMake(0,0,120,34);
gradientLayer.startPoint=CGPointMake(0.5,1.44);
gradientLayer.endPoint=CGPointMake(0.5,0.01);
gradientLayer.locations=@[@(0.1),@(1.0)];//渐变点
[gradientLayersetColors:@[(id)RGBCOLOR(255,206,198).CGColor,(id)RGBCOLOR(246,109,97).CGColor]];
[changeBtn.layeraddSublayer:gradientLayer];
changeBtn.backgroundColor = [UIColor redColor];
[changeBtnsetTitle:@"兑换" forState:UIControlStateNormal];
changeBtn.titleLabel.font=FONT(14);
[self.contentViewaddSubview:changeBtn];
效果大概是这样的
网友评论