有谁知道如何实现这个设计(swift)?
Does anyone Know how to implement this design (in swift)?
配置文件是从服务器提取的,但我不知道如何实现。一直在考虑动态 table 视图,但我不知道你是否可以那样绘制单元格。图片必须可以点击。
UICollectionView
可能是您要查找的内容(在您的屏幕截图中显示:部分/项目)。
UICollectionView Class 参考:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionView_class/
与使用 UITableView 相似。不过,您可能还想阅读一些有关它的教程。
你要的是UICollectionView。将其视为 UITableView 的通用版本。
将 A UICollectionView
添加到您的屏幕。在集合视图单元格中,放置一个图像视图,然后使用此代码创建蓝色边框和圆形图像...
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell:UICollectionViewCell = self.collectionView.dequeueReusableCellWithReuseIdentifier("BasicCell", forIndexPath: indexPath) as UICollectionViewCell
let imageView = cell.viewWithTag(1) as! UIImageView
//border
imageView.layer.borderWidth = 2.0
imageView.layer.borderColor = UIColor.blueColor().CGColor
//make imageView Circle
imageView.layer.cornerRadius = imageView.frame.size.width / 2
imageView.clipsToBounds = true
return cell
}
配置文件是从服务器提取的,但我不知道如何实现。一直在考虑动态 table 视图,但我不知道你是否可以那样绘制单元格。图片必须可以点击。
UICollectionView
可能是您要查找的内容(在您的屏幕截图中显示:部分/项目)。
UICollectionView Class 参考:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionView_class/
与使用 UITableView 相似。不过,您可能还想阅读一些有关它的教程。
你要的是UICollectionView。将其视为 UITableView 的通用版本。
将 A UICollectionView
添加到您的屏幕。在集合视图单元格中,放置一个图像视图,然后使用此代码创建蓝色边框和圆形图像...
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell:UICollectionViewCell = self.collectionView.dequeueReusableCellWithReuseIdentifier("BasicCell", forIndexPath: indexPath) as UICollectionViewCell
let imageView = cell.viewWithTag(1) as! UIImageView
//border
imageView.layer.borderWidth = 2.0
imageView.layer.borderColor = UIColor.blueColor().CGColor
//make imageView Circle
imageView.layer.cornerRadius = imageView.frame.size.width / 2
imageView.clipsToBounds = true
return cell
}