簡體   English   中英

使用CGAffineTransform時如何避免文本消失?

[英]How to avoid text disappearing when using CGAffineTransform?

我想讓按鈕在我的應用中旋轉,我有以下代碼:

- (void)setFrameForButton:(UIButton *)ok {
if ([[UIDevice currentDevice] isWildcat]) {
    if([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
        ok.frame = CGRectMake(244, 840, 280, 20);
        if (wasChanging) ok.transform = CGAffineTransformMakeRotation(M_PI * -0.50);
    }
    else {
        ok.frame = CGRectMake(372, 584, 280, 20);
        if (wasChanging) ok.transform = CGAffineTransformMakeRotation(M_PI * -0.50);
    }
}
else {
    ok.frame = CGRectMake(15.0, 375.0 ,280.0, 20.0);
}
if (wasChanging) wasChanging = NO;
}

- (void)window:(id)window willRotateToInterfaceOrientation:(int)orientation duration:(double)duration {
wasChanging = YES;
[self setFrameForButton:btn];
}

盡管當我旋轉位置時應該改變它,並且在隨后的一些旋轉之后,我按鈕上的文本消失了。 該怎么辦?

不確定是否是問題所在,但嘗試將UIButtonautoresizesSubviews屬性設置為NO 這可能會阻止UIButton嘗試以任何怪異的方式轉換其文本並將其弄亂。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM