这是我的按钮:
-(UIbutton *)createLoginbuttonForSize:(CGSize)size { UIbutton *loginbutton = [UIbutton buttonWithType:UIbuttonTypeCustom]; loginbutton.translatesautoresizingMaskIntoConstraints = FALSE; loginbutton.layer.cornerRadius = 8; loginbutton.TitleLabel.text = @"Login"; [loginbutton addTarget:self action:@selector(loginCheck:) forControlEvents:UIControlEventtouchUpInsIDe]; [loginbutton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[loginbutton(WIDTH)]" options:0 metrics:@{@"WIDTH": [NSNumber numberWithfloat:size.wIDth]} vIEws:NSDictionaryOfVariableBindings(loginbutton)]]; [loginbutton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[loginbutton(HEIGHT)]" options:0 metrics:@{@"HEIGHT": [NSNumber numberWithfloat:size.height]} vIEws:NSDictionaryOfVariableBindings(loginbutton)]]; CAGradIEntLayer *layer = [UIcolor greenGradIEnt]; layer.frame = CGRectMake(0,size.wIDth,size.height); layer.cornerRadius = 8; [loginbutton.layer insertSublayer:layer atIndex:0]; return loginbutton;}
我需要自己处理突出显示吗?
解决方法 是的,您需要自己处理突出显示.你应该看看Jeff Lamarche非常容易使用 iPhone Gradient Buttons Project,而不是自己编写代码.它完全符合你的要求.它只是2个文件,因此很容易合并到您的项目中:http://code.google.com/p/iphonegradientbuttons/source/browse/trunk/Classes/GradientButton.h
http://code.google.com/p/iphonegradientbuttons/source/browse/trunk/Classes/GradientButton.m
以下截图取自Jeff’s Blog discussing the project.
@H_403_2@ 总结以上是内存溢出为你收集整理的ios – 如何使用渐变和突出显示创建UIButton?全部内容,希望文章能够帮你解决ios – 如何使用渐变和突出显示创建UIButton?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)