UIButton忽略内容模式突出显示(adjustImageWhenHighlighted)

UIButton忽略内容模式突出显示(adjustImageWhenHighlighted),第1张

概述我使用[myButton set Image:forState:]为UIButton设置了一个UIImage; 我设置它的contentMode使用[[myButton imageView] setContentMode:UIViewContentModeScaleAspectFit]; 但是当您点击按钮时,它将返回到UIViewContentModeScaleToFill并将我的图像拉出. 使用 我使用[mybutton set Image:forState:]为UIbutton设置了一个UIImage; @H_301_2@我设置它的contentMode使用[[mybutton imageVIEw] setContentMode:UIVIEwContentModeScaleAspectFit]; @H_301_2@但是当您点击按钮时,它将返回到UIVIEwContentModeScaletoFill并将我的图像拉出.

使用adjustimageWhenHighlighted修复这个,但是然后我放宽了变暗的效果,我想保留.

有什么建议如何应付这个?

@R_@R_403_6939@_6120@
UIbutton *imageBtn = [UIbutton ...imageBtn.adjustsImageWhenHighlighted = NO;[imageBtn addTarget:self action:@selector(doSomething:) forControlEvents:UIControlEventtouchUpInsIDe];[imageBtn addTarget:self action:@selector(doHighlighted:) forControlEvents:UIControlEventtouchDown];[imageBtn addTarget:self action:@selector(doHighlighted:) forControlEvents:UIControlEventtouchdragenter];    [imageBtn addTarget:self action:@selector(doCancelHighlighted:) forControlEvents:UIControlEventtouchDragExit];-(voID)doSomething:(UIbutton *)button{    ...    [self performSelector:@selector(doCancelHighlighted:) withObject:button afterDelay:0.2f];}-(voID)doHighlighted:(UIbutton *)button{    UIImageVIEw *imageVIEw = [[UIImageVIEw alloc] initWithFrame:CGRectMake(5,5,300,300)];    imageVIEw.backgroundcolor = [UIcolor blackcolor];    imageVIEw.Alpha = 0.7;    imageVIEw.tag = 1000;    [button addSubvIEw:imageVIEw];}-(voID)doCancelHighlighted:(UIbutton *)button{    UIVIEw *vIEw = [button subvIEwWithTag:1000];    [UIVIEw animateWithDuration:0.2f animations:^{        vIEw.Alpha = 0;    } completion:^(BOol finished) {        [vIEw removeFromSupervIEw];            }];}
总结

以上是内存溢出为你收集整理的UIButton忽略内容模式突出显示(adjustImageWhenHighlighted)全部内容,希望文章能够帮你解决UIButton忽略内容模式突出显示(adjustImageWhenHighlighted)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1110749.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存