TAG

RSS订阅

收藏本站

设为首页

当前位置:主页 > 移动开发 > IOS开发 >

IOS 去掉uibutton点击高亮无效

发布时间:2014-12-31 10:53 类别:IOS开发

第一种方法:

 

setAdjustsImageWhenHighlighted   // default is YES. if YES, image is drawn darker when highlighted(pressed)

 

   UIButton *priceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [priceBtn setTag:PRICE_BTN_TAG];
    [priceBtn setFrame:CGRectMake(DISTANCE_OF_SCREEN_BORDER, 3, 63, 31.5)];
    [priceBtn setBackgroundColor:[UIColor clearColor]];
    [priceBtn setImage:[UIImage imageNamed:@"sequence_up_pressed.png"] forState:UIControlStateNormal];
    [priceBtn addTarget:self action:@selector(priceBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [priceBtn setAdjustsImageWhenHighlighted:NO];

相关属性:

 

@property(nonatomic)         BOOL         reversesTitleShadowWhenHighlighted;
 
// default is NO. if YES, shadow reverses to shift between engrave and emboss appearance

@property(nonatomic)         BOOL         adjustsImageWhenHighlighted;   //
default is YES. if YES, image is drawn darker when highlighted(pressed)

@property(nonatomic)         BOOL         adjustsImageWhenDisabled;      //
default is YES. if YES, image is drawn lighter when disabled

@property(nonatomic)         BOOL         showsTouchWhenHighlighted;     //
default is NO. if YES, show a simple feedback (currently a glow) while highlighted

 

第二种方法:

本群的Misery-iOS-武汉提到了一个巧妙的方法  正常&高亮用相同的图片

 

    [priceBtn setImage:[UIImage imageNamed:@"sequence_up_pressed.png"] forState:UIControlStateNormal];
    [priceBtn setImage:[UIImage imageNamed:@"sequence_up_pressed.png"] forState:UIControlStateHighlighted];

 

 

欢迎其他同志们补充
 

    UIImageView * iv = [[UIImageView alloc] initWithFrame:CGRectMake(250, 5, 50, 34)];
    iv.userInteractionEnabled = YES;
    UIButton * navBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    navBtn.frame = CGRectMake(0, 0, 50, 34);
    [navBtn setImage:[UIImage imageNamed:@"setting_test"] forState:UIControlStateNormal];
    [navBtn setHighlighted:YES];
    [navBtn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside];
    [navBtn setShowsTouchWhenHighlighted:YES];
    [iv addSubview:navBtn];

 

    [self.navigationController.navigationBar addSubview:iv];
猜你会喜欢....

Copyright © 2015 www.wahenzan.com 哇!很赞 版权所有 浙ICP备14030256号-1 Power by DedeCms

浙公网安备 33010602005986号

声明:本站所有文章除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系本站删除 网站管理员:758763728

360网站安全检测平台