Я анимирую UICollectionViewCell
, чтобы сжиматься при нажатии. Анимация работает, однако кажется, что текст перемещается влево и анимация по центру в течение времени, которое я установил (в этом случае, например, 0,3 секунды). Я пробовал несколько вариантов анимационной процедуры, но ситуация остается.анимация uicollectionviewcell, выравнивание текста от центра во время анимации
Вот пример текста вопроса:
И реализация кода:
func collectionView(collectionView: UICollectionView, didHighlightItemAtIndexPath indexPath: NSIndexPath) {
var currentCell = collectionView.cellForItemAtIndexPath(indexPath) as UICollectionViewCell!
UIView.animateWithDuration(0.3, delay: 0, options: UIViewAnimationOptions.AllowUserInteraction, animations: {
currentCell.backgroundColor = self.categoryArray[indexPath.row].catColor
currentCell.frame.inset(dx: 5, dy: 5)
let imageView: UIImageView = currentCell.subviews[0] as UIImageView
let imageSize = currentCell.frame.height * 0.45
imageView.frame = CGRect(x: (currentCell.frame.width/2) - (imageSize/2), y:currentCell.frame.height * 0.15, width: imageSize, height: imageSize)
let textLabel:UILabel! = currentCell.subviews[2] as UILabel
textLabel.frame = CGRect(x: 0, y: currentCell.frame.height * 0.30, width: currentCell.frame.width, height: currentCell.frame.height)
let bottomBorder: UIView = currentCell.subviews[1] as UIView
bottomBorder.frame = CGRectMake(0, currentCell.frame.height - 1.0, currentCell.frame.width, 5)
}, completion: nil)
}
В идеале я хотел бы, чтобы текст, чтобы изменить размер и оставаться в центре все время, вместо того, чтобы of "floating" влево, а затем перейти в центр
... так много улыбающихся лиц ...
oh my gosh, 'CGAffineTransformMakeScale' невероятно! Благодаря! – zillaofthegods
@zillaofthegods, да, это упрощает работу, если вы пытаетесь масштабировать весь вид с несколькими подзонами. – rdelmar