daprice / iOS-Tactile-Slider

UIControl slider that can be dragged from any point within its bounds, similar to those in Control Center and Home.app
MIT License
275 stars 38 forks source link

can we add image or view on slider #11

Open JyotsnaPiOSDEV opened 2 years ago

JyotsnaPiOSDEV commented 2 years ago

I tried to add image then it goes down from slider internal func setupLayers() { trackLayer.addSublayer(thumbLayer) trackLayer.addSublayer(outlineLayer) let uiview1 = UIView() let uiview2 = UIView() uiview1.frame = CGRect(x: 5, y: 0, width: thumbLayer.frame.width - 10 , height: 98) uiview2.frame = CGRect(x: 5, y: 0, width: 44 , height: 44) let appLightGrayColor = UIColor(red: 201.0/255.0, green: 201.0/255.0, blue: 201.0/255.0, alpha: 1.0) uiview1.backgroundColor = appLightGrayColor uiview1.layer.cornerRadius = 10 // uiview1.addSubview(uiview2) // uiview2.center = uiview1.center // uiview2.frame = uiview1.frame uiview2.center = uiview1.center uiview2.layer.contents = UIImage(named: "power-signal-white")?.cgImage uiview2.layer.contentsGravity = CALayerContentsGravity.resizeAspect // uiview1.center = uiview1.center // uiview1.addSubview(uiview2) uiview1.layer.addSublayer(uiview2.layer) thumbLayer.addSublayer(uiview1.layer)

thumbLayer.addSublayer(thumbOutlineLayer)

}
Ali72 commented 1 year ago

Check this pull request: #12