
??
目錄
一、編譯報錯/bin/sh: bad interpreter: Operation not permitted Command PhaseScriptExecution failed with a nonzero exit code
二、如何獲取UISlider滑桿的中心位置
一、編譯報錯:xx/bin/sh: bad interpreter: Operation not permittedCommand PhaseScriptExecution failed with a nonzero exit code
問題紀要:
由于想看看一下SJVideoPlayer框架源碼以及示例,結(jié)果下載之后報錯/bin/sh: bad interpreter: Operation not permitted Command PhaseScriptExecution failed with a nonzero exit code,嘗試pod install 以及pod updata 依然無效,還是報這個錯誤好奇怪,也不知道為何會報沒有執(zhí)行權(quán)限的問題
解決辦法:在工程根目錄,用這個命令來去除這個屬性:
xattr -d -r com.apple.quarantine ./*
二、如何獲取UISlider滑桿的中心位置

效果圖.gif
分享這個的解決方案思路:
在分析之前,先安利一個UI調(diào)試庫(LookinServer) ,開發(fā)必備神器。反正我經(jīng)常會用到這個。不得不說這個真的很實用。在Podfile中導(dǎo)入
# UI 調(diào)試庫
pod 'LookinServer', :git => 'https://gitee.com/chuansong16/LookinServer.git', :configurations => ['Debug']
其次就是需要下載一個Lookin的軟件。從而查看他的層次結(jié)果,從而在結(jié)構(gòu)中我們能發(fā)現(xiàn)其底層是用UIImageView去承載滾動的那個軸。

image.png
具體實現(xiàn)如下代碼:
/// ***slider初始化xxx代碼,然后添加事件
slider.addTarget(self, action:#selector(seliderProgress(_:)) , for: .valueChanged)
// 美顏度進度事件
@objc private func seliderProgress(_ slider: UISlider) {
setupBeautyProgressConstraints()
let integerValue = Int(slider.value)
beautySlider.value = Float(integerValue)
beautyProgressLabel.text = "\(integerValue)"
print("===== value:\(integerValue)")
}
/// 更新滑桿值label的約束
private func setupBeautyProgressConstraints(){
if let elementClass = NSClassFromString("_UISlideriOSVisualElement"),
let imageClass = NSClassFromString("UIImageView"){
for tempView in beautySlider.subviews where tempView.isKind(of: elementClass) {
for tempImgView in tempView.subviews where tempImgView.isKind(of: imageClass) {
beautyProgressLabel.snp.remakeConstraints{
$0.centerX.equalTo(tempImgView.snp_centerX)
$0.centerY.equalTo(tempImgView.snp_centerY).offset(-20)
}
}
}
}
}