This problem sometimes bothers me a lot. For example, if I just want to change the header text font size, I have to create the whole UIView. There is no direct instance method for UITableView like [tableView setHeaderTextFont], I think apple should really add this method.
However, this post did a good job, but it's not exactly the same with the original one. If you check the original one very careful, it has effect like 'inner glow' in photoshop, but with NSAttributedString, this can not be done (correct me if I'm wrong). It must be rendered by some private methods.
Also, the footer text style is the same.
So my question is: how to recreate the grouped tableview header/footer text style, exactly.
Thanks.
The effect you're talking about is just a 1px white shadow. It's there in the post you linked to:
label.shadowColor = [UIColor colorWithWhite:1.0 alpha:1];
label.shadowOffset = CGSizeMake(0, 1);
Are you implementing this and not seeing the effect?
Related
I am using Xcode 7.1.1 in my application I am using UIPickerView for selecting countries. It's working fine, I need two separator lines.
I tried to use this code:
[myPicker.subviews objectAtIndex:1].backgroundColor = [UIColor redColor];
[myPicker.subviews objectAtIndex:2].backgroundColor = [UIColor redColor];
but it showing line only in the bottom, in the top there is no line. Is there any way to show two lines between the bold text?
the myPicker.subviews you are trying to access is not something you know about. It does not contain what you think, that is, view or anything. Its apple private api and it can be anything. You cannot depend on it. It also depends on OS.
To make the selected text some sort of distinctly visible what you alternatively do is for all model objects create a corresponding UILabel in a loop and then use them to supply the data to the picker. Then in the
pickerView:didSelectRow:inComponent:
set some distinct property of your UILabel like change its textcolor or font.
add 1 pixel view in xib
hide both view & picker.
when you show picker..then display picker & 1 pixel view
when you click on cancel or Done remove your picker & 1 pixel view
I like to implement a night or dark theme to my application. I already searched the internet, but the existing options aren't what I am looking for. I thought of making my own "Theming class" for example:
I hava a TableView and I want to change the color of the TableView live (similar to Tweetbot). I thought I could do it this way.
#import "theme.h"
self.tableview.theme = YES;
This should be all I like to implement in my ViewControllers, as easy as possible.
then in theme.m I do all the rest, get the element and them it whenever a NSNotificationCenter message is fired. but the problem is that I am not sure where to start.
Does anyone have an idea how to make this?
I'm not quite sure what you are asking, but if you want to change colors upon your message, you could do something like
historyTable.backgroundColor = [UIColor colorWithRed:(0/255.0) green:(255/255.0) blue:(255/255.0) alpha:1];
That will set your tables' color.... if you want to make it fade in and out, there may be a kit to do that, or you could do something like:
for(int i=0; i < 50; i++){
historyTable.backgroundColor = [UIColor colorWithRed:(i/255.0) green:(255/255.0) blue:(255/255.0) alpha:1];
}
This would fade in the R value in RGB up by 50/255, probably somewhat nicely, but I haven't tested it. Of course, if you just want to jump to another another color, just use the first line.
I have a UITableView that contains more than 20 rows, each UITableViewCell contains a UITextView which I can set different UIFont, alignment and colour. When I scroll down or up there is a choppy or lagging during the scrolling, when I remove the font and text colours and alignment everything become perfect. Did Apple changes the way of redrawing text in iOS 7? This did not happen with the previous iOS versions.
instruments shows that the time consumed at dequeueReusableCellWithIdentifier:forIndexPath:
-- UPDATE Add Code
if (unit.fontName != nil ) {
textView.font = [UIFont fontWithName:unit.fontName size:unit.fontSize.floatValue];
}
if (unit.fontColor) {
textView.textColor=[self convertString:unit.fontColor];
}
else {
textView.textColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:1];
}
if ([unit.fontSize floatValue] !=0) {
textView.font = [UIFont fontWithName:textView.font.fontName size:[unit.fontSize floatValue]];
}
if (unit.textAlignment) {
switch ([summaryUnit.textAlignment intValue]) {
case 0:
textView.textAlignment = NSTextAlignmentLeft;
break;
case 1:
textView.textAlignment = NSTextAlignmentCenter;
break;
case 2:
textView.textAlignment = NSTextAlignmentRight;
break;
default:
break;
}
}
There are a lot of things going on behind the scenes in an UITableView, that might not make it obvious why it appears unresponsive.
As an example, you should not do tons of work in the tableView:heightForRowAtIndexPath: as the UITableView needs to ask for the height of every single row in your dataset, regardless of whether they are apparent on the screen or not. It does this in order to determine the content size.
It might not at all be your data or your cells that causes the problem. Complex cells with lots of subviews might render slow in the compositor. Especially if you have things like transparency.
Therefore I always put four basic rules down for myself whenever I am implementing a UITableView.
1) Always know what you need to tell the table view when you reload the data. Don't do lot's of stuff in the data source or delegate methods. Have things ready for when UITableView needs it.
2) Don't destroy and create views in the scroll cycle. By that, you should not create new UIView (or whatever) - as an example in your prepareForReuse methods. Just reset content of existing views and controls, and then reconfigure them whenever UITableView asks you to.
3) Don't have complex view hierarchies in your cells. Especially transparency and out-of-bounds content that needs to be rendered, can be cumbersome for the compositor to render at fast enough speeds.
4) Don't configure your cells in tableView:cellForRowAtIndexPath:. Just dequeue and return the cell needed. Always configure and setup your cells in the tableView:willDisplayCell:forRowAtIndexPath: delegate method.
That being said, there are some tricks that can help you. As I mentioned above, don't create and destroy views or controls in the cell's prepareForReuse method. Don't do heavyweight work at all. Just reset your views and go on. Which it might sound like you're doing, since it is the dequeueReusableCellWithIdentifier:forIndexPath: that causes your troubles.
Lastly if it is because of compositing (Instruments would show work in some Quartz-related methods) you could succeed by using the shouldRasterize and rasterizationScale of your cell's CALayer. This can sometimes speed up rendering of cells considerable.
Let me know if any of this stuff makes sense, and if it might have solved your problem.
EDIT:
PS. Yes. Apple did change the text-rendering in iOS 7. But why are you using UITextView?!? I don't know it that well, but I know it is much more heavyweight than UITextField or UILabel. Maybe you could consider using those instead. UITextView is usually for editing something that resembles documents (like the Notes app). I really think this might be what is causing your troubles.
im trying to make a menu like FIFA app but i can't put the tableview in a transparent color,so the background image can be visible, can anyone help me?? I've tried of everything, any of this answers worked for me: UITableView clear background so i really need your help.
In addition to setting the background color of the table view to clear, you have to set the background color of the table view cells. And that, at least in my experience, has been somewhat tricky and couldn't be easily done via Interface Builder (the storyboard or the xib).
So you have to set the background color on your cells directly. For example, during your tableView:willDisplayCell:forRowAtIndexPath: delegate method, you'd do something like:
cell.backgroundColor = [UIColor clearColor];
And as rmaddy points out, Apple documentation for that method states:
This method gives the delegate a chance to override state-based
properties set earlier by the table view, such as selection and
background color.
Have some very strange thing happening to me with a UITableViewCell background and was hoping if someone knows whether this is a bug.
If I set my UITableView and the UITableViewCell background colors to one of the preset color methods (whiteColor, blackColor, etc) it works fine and all the rows take the necessary color. Yet, when I use either the colorWithRed:green:blue:alpha or colorWithHue:saturation:brightness:alpha I always end up getting a white background for the table.
Is this a bug in Appleās code or am I just missing something?
what are you putting into red:green:....
I've seen lots of examples where they use ints or 0-255 and this isn't correct.
[UIColor colorWithRed:0.3 green:0.2 blue:0.2 alpha:1.0]
they should be in the range of 0-1