ios - How can I center a UIActivityIndicatorView in a UICollectionViewCell? -


i trying put uiactivityindicatorview inside each collection view cell downloads image. have appearing in each cell, refuses center itself. stays in top left corner. how can center properly?

here's how i'm doing it:

extension uiview {      func showactivityindicator(onview: uiview, withindicator: uiactivityindicatorview) {         withindicator.frame = cgrect(x: onview.frame.midx - 20, y: onview.frame.midy - 20, width: 40, height: 40)         withindicator.activityindicatorviewstyle = .whitelarge         withindicator.center = onview.center         onview.addsubview(withindicator)         withindicator.startanimating()     } } 

i call function inside cellforitematindexpath like:

showactivityindicator(onview: cell.contentview, withindicator: activityind) 

but nothing move top left corner. advice?

try this

withindicator.center = cgpointmake(self.frame.size.width/2, self.frame.size.height/2); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -