I wish this help you Instead of messing with the width and height, you could change the padding to replace the border. In .node, the border is 1px and the padding is 4px on all sides. In .highlighted-node, the border is 5px, so the padding should be 4px smaller (=0px).
How can I animate border width / color of UICollectionViewCells during layout transition?
will help you As it turns out, changes to layer properties are not caught by the animation methods on UIView like animateWithDuration. So they have to be added to the layer using CAAnimation. So, in applyLayoutAttributes, I do something like this:
hope this fix your issue I have an issue when I change border width from 1px to 0px. That changes the layout of divs. The divs should be stacked step by step in the influence of margin, but when I set the border width as 0px, the top margin becomes 0px. , You can try this