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

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

具體實(shí)現(xiàn)如下代碼:
/// ***slider初始化xxx代碼,然后添加事件
slider.addTarget(self, action:#selector(seliderProgress(_:)) , for: .valueChanged)
// 美顏度進(jìn)度事件
@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)
}
}
}
}
}