如果语言是阿拉伯语,则RangeSeekSlider应该从右到左开始

时间:2019-05-16 12:06:57

标签: ios swift uislider

我正在使用RangeSeekSlider在我的应用中显示滑块。在正常情况下,即对于所有LTR语言(从左到右),它都能正常工作。但是,当使用阿拉伯语这样的语言时,要求滑块从右到左(即与普通语言相反)开始,对我来说不起作用。

为供您参考,我尝试了以下代码,但对我而言无效,

@IBOutlet weak var sliderAmount: RangeSeekSlider!

override func viewDidLoad() {
    super.viewDidLoad()

    if AppUtils.checkIfArabic() == true{
        sliderAmount.semanticContentAttribute = .forceRightToLeft
    }else{
        self.sliderAmount.semanticContentAttribute = .forceLeftToRight
    }
    // Do any additional setup after loading the view.
}

以下是使用以下代码设置的普通滑块的屏幕截图

//MARK:- Setup Slider View

func setupSliderView(){
    sliderAmount.disableRange = true
    sliderAmount.enableStep = true
    sliderAmount.step = 500
    sliderAmount.delegate = self
    sliderAmount.minValue = 500.0
    lblAmt.text = "500"
    sliderAmount.maxValue = 25000.0
    sliderAmount.handleImage = UIImage(named: "ic_SliderHandler")
    sliderAmount.handleDiameter = 35.0
    sliderAmount.lineHeight = 7.0
    sliderAmount.hideLabels = true
    sliderAmount.tintColor = UIColor(displayP3Red: 235/255, green: 235/255, blue: 235/255, alpha: 1.0)
    sliderAmount.colorBetweenHandles = UIColor(displayP3Red: 135/255, green: 102/255, blue: 123/255, alpha: 1.0)
}

当前输出:

enter image description here

TIA。

1 个答案:

答案 0 :(得分:0)

使用以下代码解决了该问题

if L102Language.currentAppleLanguage() == "ar" { //Arabic
        UIView.animate(withDuration: 0.1) {
            self.sliderAmount.transform = CGAffineTransform(scaleX: -1, y: 1);
        }
    }

所以,现在的输出是

enter image description here