swift3 - IOS Background Gradients - Storyboard -


is there anyway show background gradients on storyboard instead of firing simulator every-time see looks like

i've created , extension

import uikit  extension cagradientlayer {      func stopwatchcolour() -> cagradientlayer {          let topcolour = uicolor(red: (11/255.0), green: (128/255.0), blue: (105/255.0), alpha: 1)         let bottomcolour = uicolor(red: (39/255.0), green: (90/255.0), blue: (78/255.0), alpha: 1)         let gradientcolours: [cgcolor] = [topcolour.cgcolor, bottomcolour.cgcolor]         let gradientlocations: [float] = [0.0, 1.0]         let gradientlayer: cagradientlayer = cagradientlayer()         gradientlayer.colors = gradientcolours         gradientlayer.locations = gradientlocations [nsnumber]         return gradientlayer     } } 

then controller

    let background = cagradientlayer().stopwatchcolour()     background.frame = self.view.bounds     self.view.layer.insertsublayer(background, at: 0) 

i recommend trying code in swift playground. swift playground executes code every time type. can see background looks , edit wish. can paste code xcode project without having run simulator.

good luck


Comments

Popular posts from this blog

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -