Possible to make the custom form of the UITexView? For example ellipse or semi ellipse form.
or a more complex case
Yes, try
atextview.layer.borderWidth = 2.0;
atextView.layer.borderColor = [UIColor blackColor];
atextView.layer.cornerRadius = 10; //adjust it to change req. shape
UPDATE: In case of change in contentInSet check this question and answer
No need for that, just make it transparent and put UIImageView with any image U like underneath it...
Related
I have a UITableView and I'd like to change its height programmatically depending on the number of cells contained in it.
Can you help me?
You can use this code
self.yourTableView.frame = CGRectMake(x,y,width,noOfCell*heightOfOneCell);
You can observe tableView.contentSize changes and bind the value to the frame, keep in mind you might run into memory issues since table view won't recycle cells
Did you tried sizeToFit or sizeThatFits:?
CGRect tFrame = tableView.frame;
tFrame.size.height = MIN([tableView sizeThatFits: CGSizeMake(tFrame.size.width,
CGFLOAT_MAX)].height,
MaximumTableHieght);
tableView.frame = tFrame;
Or try this (I don't remember which was working for me).
CGRect tFrame = tableView.frame;
tFrame.size.height = MIN(tableView.contentSize.height,
MaximumTableHieght);
tableView.frame = tFrame;
I have made a subclass for UITableViewCell and I am implementing Subtitle TableViewCell with a thumbnail image.
Following are the UITableViewCell contents:
The issue I am facing is when the data loads in TableViewCell, the subtitleLabel text gets hidden upto the height of the imageView. But when I select any Cell, it shows subtitleLabelText completely.
I have added the screenshot of the same for complete reference:
The UIImageView has frame = CGRectMake(0,0,40,40);
Try to give a clearColor background color for the cell title label -
cell.textLabel.backgroundColor = [UIColor clearColor];
It turns out I was using TableViewCell style as subtitle instead of custom. The style settings in subtitle was making the other labels to hide below them. What a silly miss!
In your nib or storyboard file, make sure that the label is below the image view in the list of subview components (it is in the left of the screen). The first subview in that list will be at the lowest level (behind every other subview, if they overlap).
write one line of code
Titlelabel.backgroundcolor = [UIColor ClearColor];
because your label has white background..and Titlelabel height is too large so label is colliding.
Let me know working or not!!!
Happy Coding!!!
What is the frame of Title Label? if its height is more, then also it may possible that it hides your subtitle Label
Here's a great tutorial which helped me when I was trying to do something like you want :
http://www.appcoda.com/ios-programming-customize-uitableview-storyboard/
You can adapt the size of the different components (ImageView, TitleLabel, Subtitle,...)
How can add a light gray shadow to a UIButton, I don't want a method to do this at the moment, it should be something like:
UIButton *button1... button1.layer.shadowOpacity = 0.8
etc, but that doesn't work, it only adds a shadow inside the button, but I need it on the outside. Thanks!
First you have to #import <QuartzCore/QuartzCore.h>. Then:
mybtn.layer.shadowColor = [UIColor blackColor].CGColor;
mybtn.layer.shadowOpacity = 0.5;
mybtn.layer.shadowRadius = 2;
mybtn.layer.shadowOffset = CGSizeMake(3.0f,3.0f);
You can also use –[UIButton setBackgroundImage:forState:] to set the background image for UIControlStateNormal to one with a shadow. E.g.:
[button setBackgroundImage:[UIImage imageNamed:#"ButtonBackgroundNormal"]
forState:UIControlStateNormal];
where ButtonBackgroundNormal.png has a shadow. Images often render faster than drawing with code. And, speed is important, especially if you're adding it to a UITableViewCell. In that case, to speed up scrolling speed, make sure the background image is completely opaque by designing it with the same background color of the UITableViewCell and saving it without transparency. Then, set button.opaque = YES.
Before mouse over:
after mouse over:
Seems like the glow effect will change its shape according to the image shape.
Is this a NSShadow? How to implement this in code? Any clues or examples? Thanks a lot.
I could with iOS but I think the same applies:
set zero offset for the shadow
blur it enough
give right size
and choose white as color.
This is what I used in my case, which is practically the same as the other answer but with code:
myImage.layer.shadowColor = [UIColor whiteColor].CGColor;
myImage.layer.shadowRadius = 4.0f;
myImage.layer.shadowOpacity = .9;
myImage.layer.shadowOffset = CGSizeZero;
myImage.layer.masksToBounds = NO;
Taken from here
I would like to have a texture on UILabel.text .
Doing so I subclassed UILabel. Using the -drawTextInRect method, I am trying to get only the text for creating an image mask with the function CGImageMaskCreate.
Once having that image mask from text I am trying to use it to create a new image by calling the function CGImageCreateWithMask.
Is that even possible?
Is that the right approach?
How do I get an image mask from the UILabel.text?
You can just set text color to pattern image:
label.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"texture"]];
Result:
Use this code. It may help you.
lbl.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"img"]];