Fix gradient rendering code so re-rendering works without crashing

The current code guesses which layer needs to be replaced and is sometimes incorrect. This pull request stores the gradient layer in a property to avoid this issue.

The crash would happen under iOS 7.x whenever a stylesheet change caused a re-render and there was at least one control using a gradient layer.