我在我的应用程序中有一个UITextView
。我希望能够在进入UITextView
的某些行之后滚动UITextView
,如iPhone的短信应用程序。
目前我有以下代码:
myTextView = [[UITextView alloc] init];
myTextView.frame = CGRectMake(45, 50, 250, 20);
myTextView.layer.borderWidth = 1.0f;
myTextView.delegate = self;
myTextView.scrollEnabled = NO;
myTextView.contentInset = UIEdgeInsetsZero;
myTextView.layer.borderColor = [[UIColor grayColor] CGColor];
[self.view addSubview:myTextView];
查看UIScrollView的setContentOffset:animated
例如,要一直滚动到屏幕底部,您可以这样做:
CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height);
[scrollView setContentOffset:bottomOffset animated:YES];