I have a custom iPhone-App what uses the barcode reader zbar.
My problem is the tracking border color what is green (my customers most hated color because its the competitors CI-color).
Is there any chance to programmatically change this color to f.e. red or blue?
Thanks in advance!
In the ZBar sdk, ZBarReaderView has a method called "TrackingColor". The default is green.
Here is the code to change the tracking color:
reader.trackingColor = [UIColor redColor];
I am using a TabBar. So here is the code I used to get it to work:
ZBarReaderViewController *reader = [tabBarController.viewControllers objectAtIndex: 0];
reader.readerDelegate = self;
reader.readerView.trackingColor = [UIColor redColor];
I hope this helps!
The problem is already solved.
With help from spadix (http://sourceforge.net/users/spadix/) this feature is added to the current SDK version.
More information here: http://sourceforge.net/projects/zbar/forums/forum/1072195/topic/4036084
Related
FIXED!
You won't believe it... It was a Winterboard theme messing with it! The bugger! Disabled theme and voila, works perfectly. The theme in question was "Ayecorn" for anyone interested. Not cool! Hope this helps anyone else who encounters the same issue.
Sorry folks, and thanks for all the input! Great community here.
Original Question:
So a simple test iPhone app in Xcode 4.5:
Create a view with a UISegmentedControl via Storyboard, and set the color via attributes inspector.
Run it on simulator, color shows fine:
Run it on device, color is see-thru/clear.
(Yes in this example above I have colored individual segments, but I even created a new project, added segment control to the view (Bar Type) and it came out see thru!? What gives?
Anyone experienced this before and have and advice on how to correct this?
Thanks
Your simulator might have cached the older images you used before. Clean your simulator and entire project to make sure the images are properly loaded on your simulator.
Try pasting below code
- (void)viewDidLoad
{
UISegmentedControl *segmentControl=[[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:#"1",#"2",nil] ];
[segmentControl setSegmentedControlStyle:UISegmentedControlStyleBar];
[segmentControl setFrame:CGRectMake(20, 20, 200, 30)];
[self.view addSubview:segmentControl];
[segmentControl addTarget:self action:#selector(changeSegment:) forControlEvents:UIControlEventValueChanged];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)changeSegment:(UISegmentedControl*)sender
{
for (int i=0; i<[sender.subviews count]; i++)
{
UIColor *tintcolor;
if ([[sender.subviews objectAtIndex:i]isSelected] )
{
tintcolor=[UIColor redColor];
[[sender.subviews objectAtIndex:i] setTintColor:tintcolor];
}
if (![[sender.subviews objectAtIndex:i]isSelected]){
tintcolor=[UIColor grayColor];
[[sender.subviews objectAtIndex:i] setTintColor:tintcolor];
}
}
}
It's possible you have the Opaque option unchecked in the Drawing section of the View Attributes.
I vaguely recall having an issue similar to this where the behaviour on the emulator was different from that of the device and it was related to the Opaque setting.
You won't believe it... It was a Winterboard theme messing with it! The bugger! Disabled theme and voila, works perfectly. The theme in question was "Ayecorn" for anyone interested. Not cool!
Thanks for all the input guys! Great community here!
I have a simple leader boards table for an iphone game that allows me to view the previous high scores however the background is black and therefore it is not visible. I am using the code:
[highscores addObject:[NSArray arrayWithObjects:#"Title",[NSNumber numberWithInt:5000],nil]];
Can I change the colour easily?
All help greatly appreciated, I expect it is simple but google is coming back with little.
Thanks in advanced!
changing the color is not related with an Array.Its related with the container who displays the Title .
you may binding the Title string to any UILabel.
So you have to set the textColor property to white.
Eg: label1.textColor = [UIColor whiteColor];
To make the UILabel white, remove this code:
[label1 setRGB:0 :0 :0];
And add do this instead:
[label1 setTextColor:[UIColor whiteColor]];
Let me know if this helps you. Posting your code definitely helps. You are doing great at age 14, so keep it up.
Hey, I was wondering how I could make the user being able to change the background of the app? I have 3 Images that the user will be able to choose from. I've seen it in many apps. How would I do this? If possible please provide some code! :)
Thank you in advance!
It's quite easy. All you need is to set the background property of your view to an image. Here's how it's done:
self.view.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:#"yourimage.png"]];
Now, when the user selects a different image, simply repeat the above code with a different image each time.
The question should be more clear.
You can change the background of the UIView or parent UIWindow by using,
view/window.backgroundColor = [UIColor colorWithPatternImage: image]
or Use the UIImageView,
imageView.image = image
I am making an iPhone app, and I want know how make a variable background image a background that the user can choose one of the options ?
I don't know what you want in the foreground, but anything based on the UIView class has a backgroundColor property that you can set to an image like this:
yourView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"YourImage.png"]];
It didn't work for me, what it worked was:
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"background.png"]];
I think is the same, but don't know why the other answer didn't work for me.
Hope it helps.
just switched to iOS 4 on my iPhone 3GS and some of my apps broke.
One issue I had is that I had a UIToolbar with some buttons, tinted to pink, that worked well on the 3.1.3 OS. After upgrading to iOS 4, the toolbar was still tinted, but the buttons it contained were no longer affected by the tint. The toolbar was pink while the buttons were regular-blue.
Looked around for it on the net, but found no reference of such a thing.
Anyone knows what broke in the process?
(must be frank here - I knew the answer before posting, just didn't know how to load this data to StackOverflow. Thought the solution I found was valuable for others, so wanted to post it here. I'm new here, so please no harsh critics :) )
So eventually the problem resulted from, AFAICT, a change in behavior in the OS.
As stated the tint code worked before the upgrade and was written like this:
// Toolbar content
NSArray *items=[NSArray arrayWithObjects: ... ]; // PSEUDO CODE HERE
[toolbar setItems:items];
// Add tint
toolbar.tintColor = [UIColor colorWithRed:0.83 green:0.43 blue:0.57 alpha:0.5];
What I needed to do, was just reverse the order of things:
// Add tint
toolbar.tintColor = [UIColor colorWithRed:0.83 green:0.43 blue:0.57 alpha:0.5];
// Toolbar content
NSArray *items=[NSArray arrayWithObjects: ... ]; // PSEUDO CODE HERE
[toolbar setItems:items];
(If you created UIToolbar in Interface Builder, you can change it's tint there, and that applies for the buttons as well).
I guess the tint updated all buttons before iOS 4, while in iOS 4 it doesn't and when adding buttons, they check for existing tint. But this is just a guess. The solution works anyhow..
Hope this helps someone, and that I didn't violate any sacred SO rules...
Cheers!
Well, it seems more like an OS bug than a feature, since navigation bars do change their item's color when you set their tintColor.
We've found that if you change the item's style, it refreshes their color as a side effect. Doing the following worked in our case. The original buttons are bordered, so we change them to plain and set them to bordered again. You may do a more complicated and generic code that saves the current style, sets another one and then switchs back. I am just to lazy to do that. :D Anyway, you get the idea.
toolbar.tintColor = //<some dynamically obtained UIColor>
// Workaround to properly set the UIBarButtonItem's tint color in iOS 4
for (UIBarButtonItem * item in toolbar.items)
{
item.style = UIBarButtonItemStylePlain;
item.style = UIBarButtonItemStyleBordered;
}
Regards,
Rula.