I have two UITableViews. One of the tables is working fine but the UILabels in the other table is blurry. I have tried changing their color programmatically. It can change the color ex: black to green but the blurry issue still remains.
This is my hierarchy of this particular view
How can I make the text clear like the first table?
You might have changed the alpha value of any of the superviews of UITableView. If you changed a view's alpha value, it affects all the subview's alpha
Set shouldRasterize = false on the CGLayer of the view containing the UILabel.
And
Your label is blurry because the frame is using floating numbers.
To force integers value for your frame just do :
[loadingText setFrame:CGRectIntegral(loadingText.frame)];
Related
Given that using the minimumInteritemSpacing / minimumLineSpacing settings on an iOS collection view creates a space rather than a solid border between cells, how can we style a solid border of consistent width around each cell in a collection view grid with a seperate colour applied as the background to the main collection view (so that after the border of the last cell a different background colour is visible) using these methods?
This is the best example of a solution I have seen so far but it is for objective C only rather than swift 3. The author also outlines the shortcomings of a couple of approaches I have already tried:
UICollectionView custom line separators
As an additional note the grid contains items of varying dimensions as illustrated here:
github.com/Antondomashnev/ADMozaicCollectionViewLayout
Edit - Here is an image of the effect I'm trying to achieve:
Custom CollectionView
It also highlights the problem that whil]1st the blue borders are most easily created using minimumInteritemSpacing / minimumLineSpacing the spaces created (whilst accurate and evenly spaced) just show the colour of the background view beneath the cells so you are left with one solid colour as opposed to the blue and yellow combination shown in the image.
I was able to get the result I wanted by setting a minimumLineSpacing and minimumInterimItemSpacing value of 0 to group the cells together and dynamically adding / removing borders as CALayers using krotov's answer here: UIView bottom border?
I have a UItableViewController, with a UITextField in each cell, pretty basic. I decided to get a bit fancy and alternate the row colors by setting the background color of the text field.
What I noticed is that the text field background color does not match up with the table rows. The width is shorter and the height and position is wrong too.
I tried setting the dimensions of the frame of the text field in cellForRowAtIndexPath. I also tried the same in willDisplayCell. I also tried to muck around with other frames, like the cell frame, to no avail.
I've had some some luck in setting the text field frame size in layoutSubviews in my UITableViewCell subclass, but it still acts strangely. When the table first displays, everything looks right. I click my edit button, and everything still looks right. I click the done button and I'm back to the old problem with both the width and height too short. Checking in the debugger, I am setting everything to the correct values.
More Information:
I have the same problem with some tables which have UILabels instead of UITextFields. All of the tables have fixed size rows. I initially set up the tables with the interface builder, but I'm trying to set the frame sizes programmatically. I am using the latest and greatest Xcode 5 (5.1.1).
Anyone have any suggestions? Where am I supposed to set the frame size? Is there another object that I should be setting the size of?
Thanks in advance
I just noticed something weird in the UIView's class reference. Under alpha it states:
This value affects only the current view and does not affect any of its embedded subviews.
But as you most certainly know, that is not the case. If you change the alpha of a superview all subviews also apply the new alpha.
Is it a mistake in the documentation or am I misunderstanding it?
This value affects only the current view and does not affect any of its embedded subviews.
I understand this as:
Changing the alpha value on a view will not change the alpha value on any subviews. As in, whilst the subviews will appear to have changed their alpha, their .alpha property value will not change when the superview's .alpha is changed.
I know you can mask an image in ios, but can you mask a scrollview? I'm wanting to alpha mask my scrollview so that the content on the ends appears to fade out before it gets clipped by the scrollview. Is something like this possible?
FYI I have already tried work-arounds that "fake" this effect and they don't work due to a dynamic background. I need strict alpha masking on the scrollview if at all possible.
You can fake this effect by laying over an image with alpha over the end of the scrollview. That way the fading effect stays in place, and the scrollView appears to fade out.
You can do this nicely by using layer masking:
create a mask with the appropriate alpha gradient
add the mask to the table
implement the scroll delegate, to reposition the mask to the current viewport when the table gets scrolled.
It is all explained very well here: http://www.cocoanetics.com/2011/08/adding-fading-gradients-to-uitableview/
Could you implement a footer (or last cell) that has the appropriate alpha fade to give you the effect you are looking for?
In my example, I have 3 views: one red view containing two white views. I change the red container view's alpha to 0.3 and this happens (look at the image, the current result).
By seeing this, I can only assume (tell me if I'm wrong) that setting a view's alpha will also set all of its subviews' alphas. My question is : is there a way to simply tell the red view to act as a whole so that setting its alpha would give something that looks like the wanted result (in the image)?
This is what it looks like without any alpha :
To elaborate on Mark's answer: If you set UIViewGroupOpacity in the Info.plist, it will change the behavior for all views in your app, if you are interested in only fixing the rendering of this particular view, you could also use this snippet:
redContainerView.layer.shouldRasterize = YES;
// No setting rasterizationScale, will cause blurry images on retina.
redContainerView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
The iOS alpha property is inherited by its subviews. If we are setting alpha 0.3 for red view then both subview will have the alpha = 0.3. There is no way to stop subviews from inheriting their alpha value from their superview.
The solution might be to set the colour of the red view with an alpha of 0.3. The color property will not be inherited by its subview.
[redView setBackgroundColor:[UIColor colorWithHue:238.0f/255.0f saturation:24.0f/255.0f brightness:24.0f/255.0f alpha:0.3]];
Check out the possible UIKit keys for Info.plist, specifically UIViewGroupOpacity.
UIViewGroupOpacity (Boolean - iOS) specifies whether Core Animation
sublayers inherit the opacity of their superlayer.
Info.plist UIKit Keys