How to make an NSTextAttachment(image) takes whole line? iOS - ios

In my UITextView, i just set NSMutableAttributeString an NSTextAttachment which is a UIImage. Though i have set the attachment width to the screen width,but when i tap the image, the input cursor will come into the right of my image.
but which i want is:
when insert an image via NSTextAttachment,there should be empty lines at the top and bottom of the image respectively,and the input cursor can only appear in the bottom or the top of the image rather than the left or right.

Related

Partially show imageview

I am trying to create an animation where an image view is moving up and down vertically. I have a line that the imageview is passing through, and my intention is to have the imageview hide partially when passing through the line. For example, if the line is halfway between the imageview, then the bottom half of the imageview should be hidden. Therefore, it would be ideal if there was a library of function that could hide a fraction of the imageview based on a specified y position. Please find examples of what I mean in the attached screenshots.
In this screenshot, the part of the circle (imageview) underneath the line should be hidden, but the top half should be shown.
Also, keep in mind that the background is a changing gradient so I wouldn't be able to use a rectangular view with the same background color to hide the circle.

Custom UITabBar with vertically aligned images

Is there a way to make a the UITabBar show just images that fill the entire TabBarItem?
I tried simply placing an image and deleting the text in the item's title but the image always appears off-center (the area where the title text was remains and I can't align the image to be over it)
Change image inset of UITabBarItem in UITabBar. You could adjust the image inset to make image bigger, smaller, shift to right etc.

Add padding to left margin of UITextField in swift

I have a UITextField with a background image set. The background image consists of a border with an icon on the left side. I'd like to move the cursor so the editing starts after the icon appears. How would I accomplish this in swift?
edit: Would it be easier have a custom border as an uimageview and the textfield placed over it and attached to it? If so what would be the best way to do this?
if you want left padding in TextField just use below code ,
youTextFiled.layer.sublayerTransform = CATransform3DMakeTranslation(5, 0, 0);
The amount of left padding you can change by changing the value of at first argument .

Show "Black" when you "Scroll" down image

I have a pretty simple scroll view (code below) which i have a picture on
self.detailViewController.scroll.contentSize=CGSizeMake(320, 1200);
self.detailViewController.scroll.showsHorizontalScrollIndicator=YES;
However when i "Scroll to the extreme button or extreme top of the picture or extreme button of the "scroll view, it loops and shows the top of the picture or loops back to the buttom of the picture.
I was wondering if there was some sort of "no repeat" i could set so it shows "black" instead of back to the top of the picture.
Thank you.
colorWithPatternImage tiles the image that it is given. So setting it as the background colour will always result in 'wrap around' if the scroll view can be scrolled outside the edges of the tile image.
To prevent this, choose one of:
Set the content size to the size of the tile image and turn off bouncing
Don't use colorWithPatternImage, use a UIImageView added as a subview of the scroll view.

iPhone - Image not align at center on UIButton

I have customized UIButton with the following properties:
84x44 frame
84x44 background image
32*32 image that should be centered
but my image is always aligned to the left. How can I align it back to center position on the UIButton?
I have a title on my button that is hidden (clearColor). These titles are key_value in a dictionary so I know which button is pressed and return corresponding value in the dictionary.
I now understand that it's these text that is pushing my image sideway, but how do I fix that?
Under attribute inspector,
there is a tap named Edge, set to Image.
I set left value as 22
and all image align to center.
Can someone explain to me how this works?
Check that your titleLabel is blank - if it has text, it will push the image to the left to make room for the titleLabel on the right.

Resources