我有一个名为父亲的UIView.内部父级嵌套了两个名为Child1和Child2的UIView.(见图)

注意:没有边距,即0个边距,包括Child1,Child2和Parent.
我试图围绕父母的角落.
parentView.layer.cornerRadius = 10
Run Code Online (Sandbox Code Playgroud)
这并没有围绕孩子们的角落.(见图)
该顶部边角都没有最终得到全面这里.底角是圆角的,因为Child2是透明的,而Child1是彩色的.父母是白色的.
到目前为止我尝试过的:
parentView.layer.cornerRadius = 10
child1.clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)
没运气
parentView.layer.cornerRadius = 10
let maskLayer = CAShapeLayer()
maskLayer.path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 10, height: 10)).cgPath
child1.layer.mask = maskLayer
Run Code Online (Sandbox Code Playgroud)
仍然没有运气
请帮帮我
我正在开发一个应用程序,其中音频被录制并转录为文本。我正在使用 Nuance Developers 提供的 Speechkit。
我要添加的功能是:
如何将音频文件保存到持久存储?
这是代码:https://gist.github.com/buildFlash/48d143217b721823ff4c3c03a925ba55
我有2个VC:CouponVC和CouponFeedbackVC.
优惠券VC收到品牌:品牌!来自其parentViewController.现在我想将brand.name传递给CouponFeedbackVC.
CouponVC.swift
var brandName: String!
override func viewDidLoad() {
super.viewDidLoad
brandName = brand.name
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "couponToFeedBack" {
if let vc = segue.destination as? CouponFeedbackVC {
print(brandName)
vc.brandName = self.brandName
}
}
}
Run Code Online (Sandbox Code Playgroud)
在CouponFeedbackVC.swift中
var brandName: String!
override func viewDidLoad() {
super.viewDidLoad()
print("viewDidLoad")
print(brandName)
}
override func awakeFromNib() {
print(brandName)
self.view.layoutIfNeeded()
}
Run Code Online (Sandbox Code Playgroud)
控制台日志
nil
viewDidLoad
nil
StayUncle
Run Code Online (Sandbox Code Playgroud)
awakeFromNib() - > …
它的顶部有一个UICollectionView ,底部有一个UITableView 。CollectionView 的屏幕比例为 1:3,TableView 的屏幕比例为 2:3(使用 equalHeight 约束设置)。
我想在tableView 滚动时更改UICollectionView的高度。
当tableView向上滚动时,我想将collectionView和tableView的equalHeights约束的乘数分别更改为1:5和4:5。这将确保tableView的高度增加而collectionView的高度减少
当tableView向下滚动时,equalHeights约束的倍数应该重置为默认值。
我尝试向 tableView 添加滑动和平移手势,但它们无法识别。
如何实现这个功能呢?
PS:希望通过使用平移手势来实现此功能,以便上下拖动逐渐改变高度。
编辑/更新
这是我正在使用的代码。
class MyConstant {
var height:CGFloat = 10
}
let myConstant = MyConstant()
Run Code Online (Sandbox Code Playgroud)
主屏VC
override func viewWillAppear(_ animated: Bool) {
myConstant.height = self.view.frame.size.height
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if (self.lastContentOffset < scrollView.contentOffset.y) {
NotificationCenter.default.post(name: Notifications.decreaseHeightNotification.name, object: nil) …Run Code Online (Sandbox Code Playgroud) ios ×4
swift ×3
uitableview ×2
audio ×1
core-data ×1
cornerradius ×1
segue ×1
swift3 ×1
swift4 ×1
uiview ×1