christianroman / CRGradientNavigationBar

Custom UINavigationBar subclass which allows gradient coloured navigation bar on iOS 7.
MIT License
916 stars 116 forks source link

Horizontal gradients? #14

Open andrewhavens opened 9 years ago

andrewhavens commented 9 years ago

This library looks like a lifesaver! I need to do something exactly like this (with a translucent gradient), however, I need the gradient to be horizontal, rather than vertical. Is this supported? Or how could I extend this library to support this feature?

Sean-Wang commented 9 years ago

+1

yudinm commented 8 years ago

For horizontal gradient can add startPoint and endPoint like:

- (void)setBarTintGradientColors:(NSArray *)barTintGradientColors
{
    // create the gradient layer
    if (self.gradientLayer == nil) {
        self.gradientLayer = [CAGradientLayer layer];
        self.gradientLayer.opacity = self.translucent ? kDefaultOpacity : 1.0f;
        self.gradientLayer.startPoint = CGPointMake(0.0, 0.5);
        self.gradientLayer.endPoint = CGPointMake(1.0, 0.5);
}