當畫面中的UITextView被塞入了大量文字,且文字數量多到畫面可以scroll
這時候就需要透過撰寫程式碼的方式,強迫畫面重新scroll至最頂端,作法如下
- (void)viewDidLoad {
[super viewDidLoad];
NSString *verylongText = @"very looooooooooooong text";
[self.myTextView setText:verylongText];
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
// make the UITextView scroll to top
[self.myTextView scrollRectToVisible:CGRectMake(0,0,1,1) animated:NO];
}
[Objective-C] Create Round UIImageView
#import < QuartzCore/QuartzCore.h>
CALayer *imageLayer = myImageView.layer;
CGFloat height = imageLayer.frame.size.height;
CGFloat width = imageLayer.frame.size.width;
CGFloat roundRadius = height > width ? width / 2 : height / 2;
[imageLayer setCornerRadius:roundRadius];
[imageLayer setBorderWidth:1];
[imageLayer setMasksToBounds:YES];
[imageLayer setBorderColor:[[UIColor redColor] CGColor]];

CALayer *imageLayer = myImageView.layer;
CGFloat height = imageLayer.frame.size.height;
CGFloat width = imageLayer.frame.size.width;
CGFloat roundRadius = height > width ? width / 2 : height / 2;
[imageLayer setCornerRadius:roundRadius];
[imageLayer setBorderWidth:1];
[imageLayer setMasksToBounds:YES];
[imageLayer setBorderColor:[[UIColor redColor] CGColor]];

訂閱:
文章 (Atom)