我已经搜索了很多以UICollectionView编程方式创建的内容,但没有一个提示使用它的最简单的方法,如何添加标签或图像UICollectionViewCell.大多数网站都建议实现UICollectionView相同UITableView,但主要区别在于我们尝试添加任何图像.在UITableView我们可以在cellForRow方法中分配imageViews cell == nil并将图像分配给where(cell != nil).但是在UICollectionView ItemAtIndexPath方法的情况下,没有cell == nil像UITableView(s )那样的条件()CellForRow.因此,我们无法UImageView在itemAtIndexPath方法中有效地分配s或标签等变量.我想知道除了UICollectionViewCell在该自定义类中继承和分配变量之外是否还有其他选择?可以任何人帮助,任何帮助表示赞赏.
我已经尝试了很多让UINavigationBar透明的东西.但我没有成功.我设置的图像是透明的.这是我的代码.有帮助吗?提前致谢.
[rootNavC.navigationBar setBackgroundImage:[UIImage imageNamed:@"NAV_BG_iphone.png"] forBarMetrics:UIBarMetricsDefault];
rootNavC.navigationBar.translucent = YES;
rootNavC.navigationBar.backgroundColor = [UIColor clearColor];
[[UINavigationBar appearance] setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColor whiteColor],
UITextAttributeTextShadowColor : [UIColor clearColor],
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
UITextAttributeFont : [UIFont fontWithName:@"pastel" size:20]
}];
Run Code Online (Sandbox Code Playgroud)