filippocamillo / FCVerticalMenu

MIT License
211 stars 34 forks source link

Customize Appearance #2

Open robmontesinos opened 9 years ago

robmontesinos commented 9 years ago

I am unable to customize properties such as textColor, font and borderColor.

I tried with the Menu as well as each individual item. I also tried disabling NavBar Appearance to no avail. I really like this control but customizing appearance is pretty important. What am I doing wrong please?

pavankris commented 9 years ago

For text color & font , i did a small workaround FCVerticalMenu* item1 = ... FCVerticalMenu *verticalMenu = ...initWithItems[item1]; item1.textColor =[UIColor blackColor]; item1.font = ... ... .. .. [verticalMenu show...];

falaix commented 9 years ago

+1

baturaykaradag commented 9 years ago

Problem is caused by the -(UIImage )image:(UIImage )img withColor:(UIColor *)color method of FCVerticalMenuItemCollectionViewCell. Replace that with following:

-(UIImage *)image:(UIImage *)img withColor:(UIColor *)color
 {
    if (color) {
        // Construct new image the same size as this one.
        return [img imageWithColor:color];
    }
return img;
}

And add following method to UIImage as category

- (UIImage *)imageWithColor:(UIColor *)color1
{
    UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context, 0, self.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);
    CGContextSetBlendMode(context, kCGBlendModeNormal);
    CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
    CGContextClipToMask(context, rect, self.CGImage);
    [color1 setFill];
    CGContextFillRect(context, rect);
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

I had to change colors in init method of FCVerticalMenu class because it seems like properties you set after init has no effect.

gotnull commented 9 years ago

I can't see the liveBlur feature targeting 8.0.

This is my code:

self.verticalMenu = FCVerticalMenu(items: [item1, item2, item3])
self.verticalMenu.backgroundAlpha = 0.5
self.verticalMenu.borderColor = UIColor(red: 77/255, green: 81/255, blue: 94/255, alpha: 1)
self.verticalMenu.appearsBehindNavigationBar = true
self.verticalMenu.delegate = self

self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "menu-icon"), style: .Bordered, target: self, action: Selector("openVerticalMenu:"))

self.verticalMenu.liveBlur = true
self.verticalMenu.liveBlurTintColor = UIColor.blackColor()
self.verticalMenu.liveBlurBackgroundStyle = .BlackTranslucent

self.navigationItem.titleView = UIImageView(imageNamed: "Squeaker_Logo_Heading")
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.backgroundColor = UIColor(red: 77/255, green: 81/255, blue: 94/255, alpha: 1)
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()

UITabBar.appearance().backgroundColor = UIColor.blackColor()
UITabBar.appearance().selectedImageTintColor = UIColor.whiteColor()
UITabBar.appearance().barTintColor = self.navigationController?.navigationBar.backgroundColor