0
何らかの理由で、私はカスタムビューを作成し、それを上書きしてmenthodをオーバーライドして文字列とimgを描画します。以下のようなだけで何か:カスタムUIViewで画面の回転を処理する方法
@implementation WaterMarkView
- (void)drawRect:(CGRect)rect {
NSLog(@"drawRect");
NSString* test = @"This is a test string";
NSDictionary *dict = @{NSFontAttributeName:[UIFont systemFontOfSize:22],
NSForegroundColorAttributeName:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0],
};
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:16], NSFontAttributeName, nil];
CGSize strsize = [[[NSAttributedString alloc] initWithString:test attributes:attributes] size];
CGRect screentBounds = [[UIScreen mainScreen] bounds];
[test drawAtPoint:CGPointMake((screentBounds.size.width - strsize.width)/2,
(screentBounds.size.height - strsize.height)/2) withAttributes: dict];
}
@end
は、それが正常に動作のViewController
....
WaterMarkView* view = [[WaterMarkView alloc] init];
view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:view];
....
に追加します。
しかし、画面が回転すると、文字列の変化が滑らかではなく醜いことがはっきりとわかります。
私は、文字列whith UILableを追加すると、それがスムーズに移行しますと、画面回転
何私は、カスタムUIViewの遷移が時に画面の回転を滑らかにするために行うことができますか?