有没有可能调整文本大小到我的UITextView?我尝试过类似的东西:
if (_myTextView.contentSize.height > _myTextView.frame.size.height)
{
_myTextView.font = [_myTextView.font fontWithSize:25];
}
Run Code Online (Sandbox Code Playgroud)
这个调整文本非常好,但我有一些文本更长,然后我需要减少我的字体大小.
我有两个UITextViews,一个位于UIView顶部的另一个UIView底部.
我使用此代码,在键盘出现时移动UIView.
- (void) viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide)
name:UIKeyboardWillHideNotification
object:nil];
}
-(void)keyboardWillShow {
// Animate the current view out of the way
[UIView animateWithDuration:0.3f animations:^ {
self.frame = CGRectMake(0, -160, 320, 480);
}];
}
-(void)keyboardWillHide {
// Animate the current view back to its original position
[UIView animateWithDuration:0.3f animations:^ {
self.frame = CGRectMake(0, 0, 320, 480);
}];
}
Run Code Online (Sandbox Code Playgroud)
当我从底部使用UITextView时,它工作得很好.但是我的问题是,当我想使用UIView顶部的UITextView时,键盘出现,UIView向上移动,但我的顶级UITextView也向上移动.请帮助我,如果用户想要从顶部在UITextView上键入文本,我不想移动UIView.
我使用此代码viewDidLoad来扩展我的UIImageView:
imageView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 3.0, 3.0);
Run Code Online (Sandbox Code Playgroud)
现在,我想回到原来的大小,1.0
我用这个动作 UIButton
imageView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);
Run Code Online (Sandbox Code Playgroud)
但是不起作用.有什么问题?