How to change SwiftUI ScrollView Indicator Color - scrollview

The title pretty much says it all. I have a scroll view and I want to change the little line on the right side that shows how far down you are to be yellow. Is there a way to do it in SwiftUI? The only method I can find is showIndicators, nothing about changing the color.

To change to light color:
ScrollView(.vertical) {
// ...
}
.preferredColorScheme(.dark)

You would need yo make your own SwiftUI ScrollView implementation or you would need to use an UIScrollView control with a UIViewRepresentable.
I have seen this tutorial how to implement a custom ScrollView with SwiftUI.
If you go with the UIViewRepresentable you can use the standard possibilities you would use for UIScrollView customisations How to change UIScrollView Indicator color?.

Related

NSWindow color not changing if I am using it as NSSheet. How resolve this issue?

I know it seems to be a trivial question however I am facing hard time to find a solution.
Please let me explain what I am doing.
How I am changing NSWindow background Color
I have generated a User defined runtime attributes Key backgroundColor of type Color for the NSWindow
Issue
The above way is working fine however when I am calling the NSWindow as NSSheet then the color of window is not changing.
Please suggest some solution for the issue. Many thanks.
This is happening because when an NSWindow is a sheet, It doesn't draw It's background color.
I think a solution to this would be to add a background view to your window and draw the background using this view instead of using the window's backgroundColor property.
Like this sample app.

Remove UITabBar horizontal separator in iOS7

I want to remove the horizontal separator line between a UITabBar and the rest of the screen. I'm asking the same question as this guy but updated for iOS7.
Setting the background image of my UITabBar doesn't alleviate the problem, nor does setting the background image of the [UITabBar appearance] object.
Is this still possible in iOS7? If so, how?
You could also hide shadow line using this code:
[self.tabBar setValue:#(YES) forKeyPath:#"_hidesShadow"];
Swift
self.tabBar.setValue(true, forKey: "_hidesShadow")
The answer to this is pretty much the same as removing the separator of a navigation bar or a toolbar.
Officially, this is only possible by setting the shadowImage to an empty image. However, a closer look at the documentation, we see that:
For a custom shadow image to be shown, a custom background image must
also be set using the backgroundImage property. If the default
background image is used, then the default shadow image will be used
regardless of the value of this property.
By using a custom background image, you would lose the blurred background translucency.
The separator is a UIImageView that is a subview of the tab bar. You can find it in the tab bar's hierarchy and set it to hidden.
This solution uses a transparent image, so it is more preferable.
Swift
tabBar.shadowImage = UIImage()
Objective-C
tabBar.shadowImage = UIImage.new;

Autolayout is not resizing Uicollectionviewcell items when animating between layouts

I have a uicollectionview cell with an image view inside that I want to resize when I switch to a larger 'zoomed in' layout.
I have placed constraints inside the cell that does resize the image view when the zoomed in layout is displayed. I am using uicollectionview setLayout animated method.
The problem is the image does not scale with animation only the collection view cell does.
The image seems to just jump into its end size with no interpolation. So the animation looks extremely choppy.
It seems as if I need to somehow control the auto layout constraints so they animate with the set layout animated method but I don't know how.
Is there a proper way to scale the cell and it's contents ?
Thanks so much!
I had (have) the same problem with Auto Layout!
Presently the simplest way I've found to deal with it is to set:
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
This causes the imageView size transition to be animated smoothly and is the only thing that I've found to work consistently with setCollectionViewLayout:animated:
You may find this answer and the linked GitHub demo app I wrote to solve a similar issue helpful.

Gesture recognizer for tap event at specific positions on the screen

I am displaying hundreds of thumbnails in my view . I know default way to handle tap on thumbnail is using UICollectionView delegate method "didSelectItemAtIndexPath" but since its many thumbnails i wanted to look into adding gestures to the screen position so when i tap on a particular spot on the screen, it will handle the event accordingly for that particular thumbnail underneath. I would like to know if it is a good/possible approach?
It would be a hell of a lot easier to use a UICollectionView.
If you need a custom layout then you can subclass UICollectionViewLayout and get some really cool dynamic layouts.
You also get the added bonus of dequeued cells meaning that you get better memory management using it.
You may find UIGestureRecognizer useful. A good tutorial to get you started is here.

How to add comment box to page?

I am trying to model my "add comment" interface with what you see in the diagram below. However, I was unable to find such a UI element in the XCode library.
Is this a customized UI element? Or can I find a UI with the same look and feel as what you see in the diagram?
You can approximate it using a UIImageView (the silver gray background) and a UITextView on top of it which has a proper cornerRadius set. You'll need to:
#import <QuartzCore/QuartzCore.h>
in order to be able to set the cornerRadius property of the UITextView like this:
textView.layer.cornerRadius = 1.0f; // play around to see what gives you the above rounded effect to your needs.
Assuming you just want the textfield shape, you can use a UIImageView as background and have a textfield or textview on top of it accordingly...Now if you want that textview to expand thats another story, you can use strechableImageWithleftCapWidth: method on the image in order to be able to strech and expand it, and then you would need to create a custom UITextView class that expands as characters are typed in...