答案 0 :(得分:0)
我认为您的代码很好,但我通常将clipToBounds = true和masksToBounds添加到false以获得我想要的结果。另外,请确保profilePicture的宽度和高度相同,并将contentMode设置为.Center
profilePicture.frame = CGRectMake(0, 0, 64, 64)
profilePicture.contentMode = .Center
profilePicture.layer.cornerRadius = (profilePicture.frame.size.width) / 2
profilePicture.layer.masksToBounds = false
profilePicture.clipToBounds = true