FAQ Database Discussion Community


Swift viewForHeaderInSection not working with custom colors [duplicate]

uitableview,swift,uicolor
This question already has an answer here: UIColor not working with RGBA value, iOS 7 - Swift 3 answers I'm experiencing very strange behaviour of the tableView's viewForHeaderInSection method: func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 30.0 } func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?...

Swift append gives missed argument error

ios,swift,uicolor
My code was fine before adding color: UIColor into my existing class. After adding color: UIColor append part of my code is giving error (missing ',' argument). I have pasted only part of my code. Please see bottom line for error. import Foundation import UIKit class DestinationType { var name:...

How to create an extension to simplify my code in Swift?

ios,swift,uicolor
I have many functions that return various UIColors. Let's take a look at this one: func deepSkyBlue() -> UIColor { return UIColor(red: 0, green: 0.69, blue: 0.98, alpha: 1) } All my UIColor functions have alpha equal to 1.0, so it'd make sense to simplify my code by creating an...

Issue comparing UIColors in Swift

ios,swift,sprite-kit,uicolor
I need to compare two UIColors, but for some reason it always return false. I tried to compare using == and .isEqual(), but neither of them seem to work. //This is a sample of the colors I have created let blue_color = UIColor(red: 122/255, green: 180/255, blue: 190/255, alpha: 1)...

Visited color links on tabs - css

jquery,css,tabs,uicolor,textcolor
I have this code: <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>RiKoV</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.8.3/themes/base/jquery-ui.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.8.3/jquery-ui.js"></script> <script type="text/javascript"> var currentTab = 0;...

UIButton – what is the default image highlight color

ios,uibutton,uibarbuttonitem,back-button,uicolor
Is there any approach how to create from some color (let's say it's [UIColor redColor]) the default highlighted shade of this color (some kind of dark red color in this case). In my case, I have a UIButton (inside of UIBarButton) and I would like to setup the titleColor for...

Change font filling color in Sprite Kit

ios,objective-c,fonts,sprite-kit,uicolor
I'm facing a problem using a "open" font with Xcode. My aim is to get a text like the following: I tried using this part of code: // Creates the 'Welcome' label node SKLabelNode *welcomeLabel; welcomeLabel = [SKLabelNode labelNodeWithFontNamed:@"Welcome-font"]; welcomeLabel.position = CGPointMake(0, 0); welcomeLabel.fontSize = 10.0; welcomeLabel.fontColor = [UIColor redColor];...

howto get the RGB Code (INT) from an UIColor in Swift

swift,rgb,uicolor
I would like to get the RGB Value of an UIColor in swift: let swiftColor = UIColor(red: 1, green: 165/255, blue: 0, alpha: 1) println("RGB Value is:"); println(swiftColor.getRGB()); <<<<<< Howto do that ? In Java I would do it as follow: Color cnew = new Color(); int iColor = cnew.rgb(1,...

Change text color of WKInterfaceLabel using NSMutableAttributedString

uicolor,watchkit,nsmutableattributedstring
I'm trying to change text color in WKInterfaceLabel using setAttributedText property. Here's the code: MyRowController *row = [self.interfaceTable rowControllerAtIndex:idx]; NSString *str_tmp = @"Test"; NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:str_tmp]; [text addAttribute:NSFontAttributeName value:[UIFont fontWithName:FONT_REGULAR size:12.0] range:NSMakeRange(0, str_tmp.length)]; [text addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, str_tmp.length)];...

How do I convert CPTColor to UIColor?

ios,objective-c,core-plot,uicolor
I have a CPTColor (from corePlot). How can I convert the CPTColor to a UIColor?

Get UIImageView CGPoints

objective-c,iphone,uiimageview,uicolor,cgpoint
i want to get all the points in my UIImageVeiw , so i can change "some" points colors without the need of UITouch .. is it possible? What i am thinking about is: get all points in uiimageview get color of each point. if the previous color= some specific color,...

cellForRowAtIndexPath and prepareForSegue return different label colors

ios,uitableview,swift,uicolor
I have a custom table view cell. Inside the cell is a label I added from the object library and I gave it a viewWithTag value of 1. The label in the table view cell has a yellow background color. Here's the code: Within cellForRowAtIndexPath I have let label =...

Image from color issue

ios,iphone,uiimage,uicolor
i am using the method below: + (UIImage *)imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0, 0, 1, 1); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } from the link . My issue is that the image returned has not the...

change the back ground color of segmented control buttons

ios,xcode,uisegmentedcontrol,uicolor
friends, I am able to change the size of segments in segmented control but i need to change the background color of the segments to orange color any detailed view will be helpful ...

UIBarButtonItem tint color not same color on device

ios,iphone,swift,uibarbuttonitem,uicolor
I have at least one UIBarButtonItem's in every UIViewController in my project, everything is in a UINavigationController and the UINavigationBar is blue and the UIBarButtonItem's should be white. In the simulator they are white... but in device they are lightgray as you can see in the pictures below: Simulator Device...

Swift: Setting UIImage as Background

ios,swift,uiimage,uicolor
My line in viewDidLoad() is complaining about not having an ! in the following statement: view.backgroundColor = UIColor.colorWithPatternImage(UIImage(named: "background.jpg")) However, when I change it to this as suggested: view.backgroundColor = UIColor.colorWithPatternImage(UIImage(named: "background.jpg")!) It gives the following error: fatal error: unexpectedly found nil while unwrapping an Optional value Again, any help...

How can I change image tintColor

ios,objective-c,uiimage,uicolor,tintcolor
I'm receiving image from a server, then based on a color chosen by the user, the image color will be changed. I tried the following : _sketchImageView.image = [_sketchImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; [_sketchImageView setTintColor:color]; i got the opposite of my goal (the white color outside UIImage is colored with the chosen color)....

Xcode - Colours look different but should be the same

ios,xcode,hex,uicolor
In my app, I am using the following color: #3D6D86 It is set to be a background color on a view controller and also to be the color for the navigation bar on a different view controller. However the problem is that the color appears different. I converted the hex...

How do I use variables in a UIColor?

swift,variables,uicolor
What type of variable should I be using for UIColor() and Why won't this code work? I am trying to using variables created in a different class to be the amounts for red, green, and blue. I did the variables the same for all the colors but get the error:...

UIColor initializer (cannot find an initializer of type 'UIColor' that accepts …) error [duplicate]

swift,uipickerview,uicolor
This question already has an answer here: Swift UIColor initializer - compiler error only when targeting iPhone5s 2 answers I know it is not an appropriate way to do this but for the purpose of learning I have a picker control with four components and 255 rows in each...

How to set same title color of UIButton for different states?

ios,objective-c,cocoa-touch,uibutton,uicolor
I have created an instance of UIButton and want to set the title color for Normal state, Selected state and Highlighted state. And I am doing so as- [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; [button setTitleColor:[UIColor redColor] forState: UIControlStateSelected]; [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted]; with above code when I build and run the...

Issue with using RGB colors in IOS

objective-c,ios7,uibutton,xcode6,uicolor
I want to use RGB color to set set background color of UIButton. I have lots of UIButtons so I decided to make a custom class.But when I try to use colorWithRed I am getting error. First Code: [self.layer setBackgroundColor:[UIColor colorWithRed:60/255.0f green:146/255.0f blue:180/255.0f alpha:1.0f]]; Error Second Code self.layer.backgroundColor = [UIColor...

Assigning UIColor values to macros

ios,objective-c,macros,global-variables,uicolor
This question refers to this SO post: How to set global variable with UIColor class The accepted answer suggests defining a macro like so: AppDelegate header: // AppDelegate.h #import <UIKit/UIKit.h> #define black = [UIColor blackColor] #define myColor = [UIColor colorWithRed:(238.0f/255.0f) green:(251.0f/255.0f) blue:(255.0f/255.0f) alpha:0.8f] @interface AppDelegate : UIResponder <UIApplicationDelegate> @end ViewController...

Gradient through all RGB colors

ios,swift,gradient,uicolor
I am trying to create a fluent color transition through all rgb color combinations and their complement, my attempt so far is: var count = x // this is the index of the current color var red = CGFloat((count >> 16) & 0xFF)/255.0; var green = CGFloat((count >> 8) &...