使用UIView animateWithDuration
,我将UITableView
alpha 设置为 0,以便它在消失的动画中消失。但是,我注意到当UITableView
褪色时,每个单元格上的某些区域在褪色前会变黑。如果有图像,它后面的整个区域在淡入淡出时会变黑,通常左右边缘的插入空间都会变黑。我已经尝试将子视图的所有背景颜色设置UITableViewCell
为白色,但它仍然不起作用。
这个 tableview 没有嵌入到 UITableViewController 中。相反,它是一个单独的浮动 tableView,我将其用作菜单。
以下是它褪色时发生的情况的示例:
这也是我正在使用的代码
[UIView animateWithDuration:ImageViewControllerBarsAnimationDuration delay:0 options: UIViewAnimationOptionAllowUserInteraction animations:^
{
if (self.menu.superview)
{
self.menu.alpha = 0;
}
}
completion:^(BOOL finished)
{
if (self.menu.superview)
{
[self.menu removeFromSuperview];
self.menu.alpha = 1;
}
}];
+
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
UITableViewCell *tableViewCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (tableViewCell == nil)
{
tableViewCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}
[[tableViewCell textLabel] setFont:[UIFont fontWithName: @"Helvetica-Bold" size: 17]];
[[tableViewCell textLabel] setText: [self.menuItems objectAtIndex:0]];
[[tableViewCell imageView] setImage: [self.menuItems objectAtIndex:1]];
return tableViewCell;
}