i'm making a draw application, and i want a slider to appear when the user taps on a button, for example to set the width of a line . Can I just add an alert and put a slider in it ?
Welcome to Stack Overflow.
Your question is more of a basic programming question than a Swift question.
I don't think you can put a slider in an alert. Apple introduced the UIAlertController class recently, and their docs say you should us that rather than UIAlertView for new development.
A UIAlertController lets you create alerts and action sheets, and add actions. The actions are shown as buttons. There is also a facility for adding text fields. I don't think there is any facility for adding other view objects like sliders however.
The now-deprecated UIAlertView is also not set up for adding custom fields like sliders.
You could put the slider on your view somewhere and set it's hidden property to true, then in the buttons action method, set mySlider.hidden = false.
However it sounds like you want your slider to appear on top of your UI, then go away when the user is done with it.
You could create a view with a slider and a dismiss button on it, put it on top of your view controller's content view, and set it's hidden flag to true. When the user taps your button, set hidden = false and the view will appear on top, rather like an alert does. You'd set up constraints so the slider-containing view would be centered on the screen and sized appropriately.