i'm trying to immitate the count-label that is used in apples mail app, which shows the count of messages in a folder / mailbox. The text color is white, and the labels background is gray/blueish with rounded corners. (screenshot)
To get the same look, i made a custom UITableViewCell for my table, and tried to style the corresponding label like this:
label.layer.cornerRadius = 10.0;
This code basically looks like the mail app. However the performance of this code seems to be really poor. i've installed the app on my iphone 3gs, and when scrolling the table, the view is moving really slow and unsmooth. when i disable the rounded corners, its running great again.
is my code somewhat wrong, or what can i do to improve performance? should i use png backgrounds rather than rounded corners? if so, what would i need to do to have the png background adjust its width according to the label width/text length? i already added code to do this and it works, but i think for png backgrounds it would just strech/distort the background image, right?
It sounds like using cornerRadius may force CALayer to do clipping, which is expensive. You can also "can" the shape as a stretchable image (which could be used as a background image on a UIView descendant) or draw it using CGPaths or UIBezierPaths.
the simplest way is you make a bakground image and use it this is simple siloution and if you want to by coding then it is difficult because UIlabel is not have redious corner
Related
Simple I have UIImageView icon with two people and it looks like this:
but when I set tintColor to red it looks like this:
Is there any way to avoid covering every non zero-alpha pixel? I need to show the tie really there. One time I need people red, other time green.
The icon is simple png file. Rounded circle is simple background color of UIImageView. So the part of the image with tie cannot be zero-alpha.
Is there any way to achieve such effect WITHOUT creating images for every color?
This was similar to another idea I had been playing around with, so I did a little more fiddling...
Starting with these 3 images:
and then using them as .withRenderingMode(.alwaysTemplate) to give the desired colors... and then layering them via CALayer to get:
and an "exploded" view for clarity...
Create an image where the "people" are 100% transparent - effectively "holes" in the image.
Set the background color of the UIImageView to be the "fill" color.
You can still mask it with a circle (CAShapeLayer, for example), if you don't want a white bounding-box as part of the image.
Original images:
https://i.stack.imgur.com/eFrmB.png
https://i.stack.imgur.com/2GNDX.png
Use the CISpotColor filter:
https://developer.apple.com/library/content/documentation/GraphicsImaging/Reference/CoreImageFilterReference/#//apple_ref/doc/filter/ci/CISpotColor
This allows you to specify a color in your image that is to be changed into another color. Thus, since you know the original color of the tie and the background, you can change either of them, or both, in a single move.
I have created a nice looking collection view with image cells inside. I wanted the cells to be round so I made maskToBounds equal to true and set the corner radius to half of the image's width. This all works fine but now I want to add shadow effects to the cells and there are 2 problems:
I want to have an outer shadow on some of the cells (which is currently being cropped off because I set masktoBounds to true...
I want t have an inner shadow effect on some other cells (they are supposed to look less highlighted), but I don't even know how to make an inner shadow...
Any help desperately appreciated,
I work with C# in Xamarin.iOS by the way, but I will also understand any other language.
Cheers!
Take a look to the UIView.Layer.ShadowX and play with the values of it I recommend to use an image instead to simulate the effect because the Layer effects will kill your device processor
Take a look at the XamSvg component. You create 2 svg with a gradient to mimics an inset and an outset. As it is an svg, it is stretchable and could be set as your cell's background to simulate your shadow.
I am trying to make Apple kind of shape for progressHUD. I have option to use .png Image but I cant because I have to fill the apple Shape with different colour depends of percentage status.. I am using UIView to draw this shape...
I want suggestion how to draw apple kind of shape easily?
And How we can fill half colour with different colour?
I have option to use .png Image but I cant
Yes, you can. — Get hold of some apple-shaped artwork. Use it as a mask - it punches a hole in a view. Now put another view behind it, with a color. Now the apple appears to be that color, because that color is being seen through the apple-shaped hole. Now put another view behind it, with a different color, and move it up or across the right amount so as to divide what's seen through the apple into two colors.
Using that approach, it took me about 30 seconds to create this result (using your apple-shaped artwork as a .png image!):
I found this UI online, the UI looks amazing, is there any tips on creating such a thing. It seems a customed UITableView.
Many Thanks!
It's a UITableView with a custom background image and what looks like custom layers with masking (for the date and tags).
Here's a library for generating tags, though you could easily just create the layers yourself. There's alot of answers on SO like this one which will explain how to mask text on a layer. The textured look on everything is because the opacity of the layers is not quite 100%.
As for the background images I'm betting the first one doesn't include the background cell and just has the transparent cutout which shows the background. The other cells most likely have the adjacent cell "background" in the background image (since cells don't overlap). Alternating backgrounds are set based on whether the indexPath.row is even or not.
The "0/2012" date on the left side looks like a UILabel that's been rotated 90 degrees and stroked.
The rest of the cell is just standard text and an image.
Hello: Currently in my project, I'm using OBShapedButton to process touches on a lot of objects that overlap (it's a map with each territory its own separate object). Basically, this library prevents a touch from being processed on a transparent point on the given view.
I'm attempting to add a border effect to just the edges of the opaque part of the UIImage (and adding a semi-transparent overlay above that). Something to the effect of this:
Which can be simplified to this (example of one image):
I am currently using MGImageUtilities to color in the opaque parts of territories using this line:
[territory setImage:[[territory image] imageTintedWithColor:tint]];
The problem is that I'm not sure how to just color the borders (which can be any shape). I've looked at this link already, but haven't been able to come up with anything.
Thanks in advance for the help!
Terribly hacky, but use MGImageUtilities' UIImage+ProportionalFill with scale resizing to create a slightly larger image, UIImage+Tint to red, and stack below.
The library you are using doesn't actually specify a shape layer. It uses alpha values from the PNGs that you give it.
Could you use a different 'highlighted' or 'selected' PNG that adds the border effect you are looking for?
Otherwise, it you will have to generate a UIBezierPath from your PNG image, which sounds like a very computationally intensive operation. At that point, I might question whether this library meets your needs.