2014-04-16 10 views
6

मेरे पास एक बड़ा टेक्स्ट है और मैं एक नवीनतम आईओएस अनलॉक करने के लिए स्लाइड के समान प्रभाव जोड़ना चाहता हूं और यह नीचे से नीचे तक स्लाइडिंग के साथ ऊपर से नीचे तक जायेगा।UITextView या UILabel पर प्रभाव अनलॉक करने के लिए स्लाइड कैसे जोड़ें?

उत्तर

6

मैं सुझाव है कि आप अनुदान पॉल्स के शिमर नियंत्रण का उपयोग करें, क्योंकि यह सिर्फ इतना है कि करता है इस link..hope देखें।

https://github.com/facebook/Shimmer

example

+1

वास्तव में यह नहीं है प्रभाव अनलॉक करने के लिए iPhone की स्लाइड, अंडाकार है की तरह या हीरे के आकार का प्रभाव –

+0

अरे क्या आप कृपया इससे बेहतर कुछ और सिफारिश कर सकते हैं। –

+0

फिन गेडा मुझे अपना आईडी दें, मैं आपको कोड भेजूंगा, मैं वास्तव में क्या देख रहा हूं लेकिन इसे सही तरीके से नहीं मिला। –

2

तेज झिलमिलाता लेबल के साथ अद्यतन, आदि ...

import UIKit 
import QuartzCore 

class ViewController: UIViewController { 

    @IBOutlet var testLabel: UILabel! 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     self.testLabel.startShimmering() 
    } 
} 

extension UIView { 
    func startShimmering() { 
     //  let light = UIColor.init(white: 0, alpha: 0.1).cgColor 
     let light = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor 
     let dark = UIColor.black.cgColor 

     let gradient: CAGradientLayer = CAGradientLayer() 
     gradient.colors = [dark, light, dark] 
     gradient.frame = CGRect(x: -self.bounds.size.width, y: 0, width: 3*self.bounds.size.width, height: self.bounds.size.height) 
     gradient.startPoint = CGPoint(x: 0.0, y: 0.5) 
     gradient.endPoint = CGPoint(x: 1.0, y: 0.525) 
     gradient.locations = [0.4, 0.5, 0.6] 
     self.layer.mask = gradient 

     let animation: CABasicAnimation = CABasicAnimation(keyPath: "locations") 
     animation.fromValue = [0.0, 0.1, 0.2] 
     animation.toValue = [0.8, 0.9, 1.0] 

     animation.duration = 1.5 
     animation.repeatCount = HUGE 
     gradient.add(animation, forKey: "shimmer") 


    } 

    func stopShimmering() { 
     self.layer.mask = nil 
    } 

} 
संबंधित मुद्दे