【发布时间】:2017-11-12 17:46:19
【问题描述】:
我正在使用 google 地方,我有一个带有 tableView 的 VC,我从用户位置下载附近的地方,并且在 tableView 的每个单元格中我添加了地方的信息和它的照片。我创建了一个自定义类来使照片圆形
import UIKit
@IBDesignable
class RoundImage: UIImageView {
@IBInspectable var cornerRadius: CGFloat = 0 {
didSet {
self.layer.cornerRadius = cornerRadius
}
}
@IBInspectable var borderWidth: CGFloat = 0 {
didSet {
self.layer.borderWidth = borderWidth
}
}
@IBInspectable var borderColor: UIColor = UIColor.clear {
didSet {
self.layer.borderColor = borderColor.cgColor
}
}
}
但问题是我下载了这个班级的地方的照片
import UIKit
private let widthKey = "width"
private let heightKey = "height"
private let photoReferenceKey = "photo_reference"
class QPhoto: NSObject {
var width: Int?
var height: Int?
var photoRef: String?
init(photoInfo: [String:Any]) {
height = photoInfo[heightKey] as? Int
width = photoInfo[widthKey] as? Int
photoRef = photoInfo[photoReferenceKey] as? String
}
func getPhotoURL(maxWidth:Int) -> URL? {
if let ref = self.photoRef {
return NearbyPlaces.googlePhotoURL(photoReference: ref, maxWidth: maxWidth)
}
return nil
}
}
我想知道如何调整它,因为使用这个类,即使我将 RoundImage 类放在情节提要的图像视图中,我下载的照片始终是方形的
【问题讨论】:
标签: ios swift uitableview swift3 google-places-api