OC Extension GradualChange(控制元件漸變顏色)
阿新 • • 發佈:2021-02-10
技術標籤:UI的封裝iosobjective-cswiftxcode
**
一直覺得自己寫的不是技術,而是情懷,一個個的教程是自己這一路走來的痕跡。靠專業技能的成功是最具可複製性的,希望我的這條路能讓你們少走彎路,希望我能幫你們抹去知識的蒙塵,希望我能幫你們理清知識的脈絡,希望未來技術之巔上有你們也有我。
**
使用
@property (nonatomic,strong)UILabel *label;
@property (nonatomic,strong)UIButton *btn;
UILabel* testLabel = [[UILabel alloc] initWithFrame: CGRectMake(100, 200, 400, 50)];
testLabel.text = @"label上漸變方法1";
testLabel.font = [UIFont systemFontOfSize:30];
[self.view addSubview:testLabel];
[GradualChange TextGradientview:testLabel bgVIew:self.view gradientColors:@[(id)[UIColor redColor].CGColor, (id)[UIColor greenColor].CGColor, (id)[UIColor blueColor].CGColor] gradientStartPoint:CGPointMake(0, 1) endPoint:CGPointMake(1, 1)];
_btn=[[UIButton alloc]initWithFrame:CGRectMake(10, 230, self.view.frame.size.width-20, 100)];
[self.view addSubview:_btn];
_btn.titleLabel.font=[UIFont systemFontOfSize:30];
_btn.titleLabel. numberOfLines=0;
[_btn setTitle:@"button上字型漸變色設定" forState:UIControlStateNormal];
[GradualChange TextGradientControl:_btn bgVIew:self.view gradientColors:@[(id)[UIColor redColor].CGColor, (id)[UIColor greenColor].CGColor, (id)[UIColor blueColor].CGColor] gradientStartPoint:CGPointMake(0, 1) endPoint:CGPointMake(1, 1)];
效果