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
Post a Comment