Iphone Can';似乎无法通过UIImage和UITableViewCell解决此问题;s内容视图
我需要我的细胞的图像视图有一个44x44像素的区域,以便它可以点击。然而,当我尝试这样做时,我的26x26图像在未经我允许的情况下被缩放到44x44,所以现在我的26x26图像很大而且模糊。我需要将26x26图像保持在26x26,但同时将imageView帧增加到44x44。这就是我所做的,但没有奏效:Iphone Can';似乎无法通过UIImage和UITableViewCell解决此问题;s内容视图,iphone,ios,objective-c,uitableview,imageview,Iphone,Ios,Objective C,Uitableview,Imageview,我需要我的细胞的图像视图有一个44x44像素的区域,以便它可以点击。然而,当我尝试这样做时,我的26x26图像在未经我允许的情况下被缩放到44x44,所以现在我的26x26图像很大而且模糊。我需要将26x26图像保持在26x26,但同时将imageView帧增加到44x44。这就是我所做的,但没有奏效: //UITableViewCell subclass method - (void) layoutSubviews { [super layoutSubviews]; self
//UITableViewCell subclass method
- (void) layoutSubviews {
[super layoutSubviews];
self.imageView.frame = CGRectMake(0, 0, 44.0, 44.0);
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
}
//TableView method
-(void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
UIImage *originalImage = [UIImage imageNamed:@"unchecked.png"];
CGRect screenRect = CGRectMake(0, 0, 26.0, 26.0);
UIGraphicsBeginImageContext(screenRect.size);
[originalImage drawInRect:screenRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
尝试将内容模式设置为中心:
self.imageView.contentMode = UIViewContentModeCenter;
伙计,你在用44x44holy moly强制绘制图像,你是个天才。